views:

410

answers:

1

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.

A: 

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
Trip