abloom (owner)

Revisions

gist: 110019 Download_button fork
public
Public Clone URL: git://gist.github.com/110019.git
Embed All Files: show embed
controller.rb #
1
2
3
4
5
6
7
8
9
10
class Controller < ActionController::Base
  def update_all
    keys = params.keys.find_all{ |k| k =~ /obj_\d+/ }
    keys.each do |key
      id = key.split("_").last
      obj = Object.find(id)
      obj.update_attributes(params[key])
    end
  end
end
view.html.erb #
1
2
3
4
5
6
7
<% form_tag { :controller => "controller", :action => "update_all" } do %>
  <% @objects.each do |obj| %>
    <% fields_for "obj_#{obj.id}" do |f| %>
      <%= f.text_field :name %>
    <% end %>
  <% end %>
<% end %>