There are a few options for editing a model in-place while in the Show page, i.e. without having to load a form in the Edit page. For example, see http://www.ruby-toolbox.com/categories/rails_in_place_editing.html.
Has anyone had any experience using any of these options (or others) in Rails 3? Any pointers or advice?
In my case, I have a fairly long form composed of a variable number of items. From a usability point of view, it makes good sense to edit the text in these items in the same page, instead of needing an Edit button for each one that sends the user to an edit page for the particular item.
Excellent question!
in_place_editing is by dhh, Rails creator. It's maintained by the Rails core team. So it certainly should be looked into.
Hobo is a large framework that features in-place editing front and center. It's a smooth package but may be more than what you want or need.
Updated for Rails 3 Ryan of Railscasts recommends the Best in Place gem. See the Railscast with sample code and more info.
Sure it makes sense to me. I do it all the time.
For example, I am working on a complex polymorophic nested model form and it only has two views. An index, and a partial for dynamically adding more attributes to it.
If you know AJAX, that can really help your UI in that your users will not even have to click a save button.
To accomplish a bare minumum of this. Set up an index.html.erb with your form inside it.
In your controller, you could specify your actions like so :
def update
@quick_fact = @organization.quick_facts.find(params[:id])
if @quick_fact.update_attributes(params[:tab])
flash[:notice] = 'Text Tab was successfully updated.'
redirect_to quick_facts_organization_path(@organization)
else
render :action => "index", :id => params[:id]
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With