Rails editing multiple records at once

Posted by Joseph Silvashy on Stack Overflow See other posts from Stack Overflow or by Joseph Silvashy
Published on 2010-04-02T03:57:58Z Indexed on 2010/04/02 4:03 UTC
Read the original article Hit count: 212

Filed under:

I feel like this might be really simple but I'm just not getting it right, so I have like a settings page in my app and I want each setting to be like a key value store, for example:

+-------------------+--------------------------------+
| setting           | value                          |
+-------------------+--------------------------------+
| twitter_username  | something                      |
+-------------------+--------------------------------+
| facebook_url      | http://facebook.com/someguy    |
+-------------------+--------------------------------+

My form looks something like this:

<% form_tag set_admin_settings_path, :method => :put do %>
  <ol>
  <% for setting in @settings %>
    <li class="field">
      <label><%= setting.setting_name.humanize %></label>
      <%= text_field_tag "[setting_value][]", setting.setting_value %>
    </li>
  <% end %>  
    <li class="submit">
      <%= submit_tag "Update settings" %>
    </li>
  </ol>

<% end %>

Everything renders fine but when I try to save the form, nothing is saved :(

© Stack Overflow or respective owner

Related posts about ruby-on-rails