Reputation: 909
I am sure this is common requirement but I am new to rails and I have tried searching for the problem but haven't had much luck.
I have a form and I have pre-populated it with values from the database for the specific entry. The user should be able to change those values and then hit the 'edit' button which then then go and edit the values in the database.
I want to call the edit action from within a page without using the standard /1/edit url path. Basically I want to call .find(params[:id]) by passing the id of a particular entry directly into the method.
What is the best 'rails way' of doing this?
Thanks for your help.
Upvotes: 0
Views: 105
Reputation: 3919
Or you could go one step further and use the in_place_editing gem. No need for a button and remote forms.
Upvotes: 0
Reputation: 15089
This particular method is being called within a button press? A link click? A focus change?
You can always send parameters to the server like this:
<%= link_to "Your action", yourcustomaction_path(:id => @object.id) %>
Or like this:
<%= text_field_tag "yourattribute", params[:this_field_attribute] %>
You don't have to always call the default edit action, you can simply create another route in routes.rb
Upvotes: 1