Hey all,
this is my first post and i hope you can help me!
I have a table with 'papers' and i have to assign a 'shepherd' to a paper!
i created a list of all papers and a select to choose a shepherd for which paper, but when i push confirm the controller don't have the shepherd info.
heres my code:
assignshepherd.rhtml
HTML Code:<h1>Listing papers</h1> <table> <tr> <th>Paper</th> <th>Author</th> <th>Shepherd</th> </tr> <% for paper in @papers %> <tr> <td><%= paper.title %></td> <td><%= paper.author.user.name %></td> <td><select id="shepherd_id_<%=paper.id%>" name="shepherd_id_<%=paper.id%>"> <option selected="selected">Assign Shepherd Here</option> <%= options_from_collection_for_select @shepherds, "id", "user_id", paper.shepherd_id%> </select></td> </tr> <% end %> </table> <br /> <%= submit_tag "Back", {:type => 'button', :onClick=>"parent.location='" + url_for( :controller => 'paper', :action => 'list' ) + "'" } %> <%= submit_tag "Confirm", {:type => 'button', :onClick=>"parent.location='" + url_for( :controller => 'paper', :action => 'confirm' ) + "'" } %>
paper_controller.rb:
Code:def confirm @papers = Paper.find_all @papers.each do |paper| @paper = Paper.find(paper.id) @paper.update_attribute(:shepherd_id, params["shepherd_id_#{paper.id}"]) end redirect_to :action => 'assignshepherd' end



Bookmarks