Friday, June 17, 2011

[Rails] Controlling multiple form_for with javascript -- please help!

In the show.html.erb view of users (/users/1/), I have a form that
allows the user to "post" a msg (e.g., "I took out the trash.")
Currently, I have that connected to a facebook_controlller.rb, that
sends a status update to the user's FB account if they have "connected
with facebook" on our site. I want to allow users to control whether
their post would be broadcasted via facebook, so I added a
check_box_tag to the form_for posting to act as a gate.

Suppose you log in and you post something, then a partner (e.g., think
of it as a Twitter follower) can log in and rate your msg on the same
page using a link_to url_for (....).

I have a similar FB status update if you rate a msg (it posted "I just
rated my partner's msg...") I tried adding a similar check_box_tag
for the ratings, and I'm trying to pass a ":share" parameter to the
ratings_controller.rb from the users_controller.rb

Here's the problem:
1. if I use a check_box_tag on the same page, then when the rate url
is clicked, the msg form_for post gets triggered and there's an
error.

2. I tried implementing javascript so that I could target which form
on the page gets activated (form_1 = msg post; form_2 = check_box),
but it seems that I can't get the DOM to identify the check_box_tag.

3. I tried creating a separate form_for the ":share" parameter. But
the app breaks, stating that there is an undefined method (presumably
because I initialized @share = params[:share] in the
users_controller.rb; while the app is expecting a model not a
variable).

Any and all thoughts on this are welcome!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate