I’m new to Ruby on Rails and i have an issue.
I have 2 forms which edit the same model, but in the update method I have to give a different JS response depending on the form which submitted.
How do I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just add a
hiddeninput field to your form specifying where it comes from.Then, in your controller, access this field through the
params[:field_name].Create the form by using something like:
This will render as something like:
In your controller, check which value this hidden field had, and use
renderto render your JS response (or whatever you specifically use). See Layouts and Rendering for more info.