Skip to content

Commit

Permalink
Added select box to edit page. Closes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
manner committed Nov 9, 2017
1 parent adb8d77 commit 0d5f2a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/papers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def destroy

private
def paper_params
params.require(:paper).permit(:title, :venue, :year)
params.require(:paper).permit(:title, :venue, :year, { author_ids: [] })
end
end
6 changes: 6 additions & 0 deletions app/views/papers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
</p><p>
  <%= f.label :year, "Year" %><br>
    <%= f.text_field :year %>
</p><p>
<% 5.times do | i |%>
<%= f.label "Author #{i + 1}", for: "paper_author_id_#{i + 1}" %>
<%= f.collection_select :author_ids, Author.all, :id, :name, {selected: @paper.author_ids[i], include_blank: '(none)'}, {name: "paper[author_ids][]", id: "paper_author_id_#{i + 1}"} %>
<br>
<% end %>
</p><p>
<%= f.submit %> </p>
<% end %>
2 changes: 1 addition & 1 deletion app/views/papers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= @paper.year %>
</p>
<p>
<strong>Author:</strong>
<strong>Authors:</strong>
<ul>
<%= @paper.authors.each do |author| %>
<li> <%= author.name %> </li>
Expand Down

0 comments on commit 0d5f2a2

Please sign in to comment.