English 中文(简体)
in-place edit in Rails 3
原标题:

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




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签