Is it possible to pass a hash as a checkbox value?
My controller passes an array of hashes (@citations) and my view loops through this array and displays the values of the hash as shown below.
Here is my code for my form.
<%= simple_form_for @user do |f| %>
<ul class="publications">
<% @citations.each do |publication| %>
<li>
<div class = "PublicationString">
<%= check_box_tag "publications[]", publication %>
<%= publication[:title] %>
<%= publication[:authors] %>
<%= publication[:journal] %>
<%= publication[:year] %>
<%= publication[:volume] %>
<%= publication[:pages] %>
</div>
</li>
<% end %>
<div class="actions">
<%= f.submit "Add to profile" %>
</div>
</ul>
<% end %>
What I need to do is pass an array of hashes back to the controller and then for the controller to loop through the array, and for each hash create a new publication in my publications table (which has columns for each of the hash values).
Is it possible to pass a hash as a value of a checkbox?
Many thanks
Aucun commentaire:
Enregistrer un commentaire