Editing multiple objects with simple_form

1.6k views Asked by At

In the Railscast dealing with Editing Multiple, Ryan shows how to edit multiple objects in batch with form_tag. Is there a good way to do this using simple_form?

1

There are 1 answers

0
Lanny Bose On BEST ANSWER

The base-case for using form_for or simple_form_for helpers are to hand them an ActiveRecord model...

<%= form_for @zebra do |f| %>

...which doesn't work in this case because you're not creating a form for one single instance of an ActiveRecord model. In the RailsCast, this is why Ryan uses form_tag.

There isn't a simple_form_tag, but you can hand simple_form a :symbol instead. Check out this SO post to see how some folks approached a similar problem. Know that at that point, you're writing a lot of extra code for simple_form to do what the RailsCast code does instead, and you lose a lot of the built-in niceties of simple_form.

There might be really good reasons why you'd battle with simple_form in this non-ideal scenario. If it were me, I'd start with the RailsCast code, get it working, and worry about niceties second. :)