mardi 14 avril 2015

Rails simple-form with multiple instances of the same object

I am trying to create a rails form using simple form that uses nested resources. However, I want to be able to submit multiple instances of the associated resource. Example below will probably explain it better.



<div class="tab-pane active" id="reminder">
<%= simple_form_for @collection, html: {multipart: true}, url: collection_index_path do |m| %>

<%= render partial: "collection/tabs/reminder", locals: { :m => m } %>
</div>


-inside partial



<% j = 1 %>
<% 9.times do %>
<div class="tab-pane" id="<%= j %>">
<%= m.simple_fields_for :reminder do |p| %>
<%= p.input :heading %>
<%= p.input :message %>
<% end %>
<% j += 1 %>
</div>


There is a tabbed pane in which the user can click through 9 tabs to set up to 9 reminders, all should be associated with a collection (collection model accepts nested attributes for reminder). However, the way I have it setup now, the controller only gets what was set in the last reminder in the params. Anyway ideas would be appreciated.


Aucun commentaire:

Enregistrer un commentaire