Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have User, Prog, Enrollment model associated has_man through. Idea is that User adds Prog to profile and Prog can accept User's request or decline.

<% @prog.users.each do |user| %>
<%= link_to "Accept Application", controller: "/enrollments", action: "accept", method: "post", id: user.id %>/
<% end %>

enrollments_controller
def accept
@enrollment = Enrollment.find_by_user_id(params[:id])
@enrollment.status = "accepted"
@enrollment.save!
redirect_to progs_path, notice: "added"
end

I undestand that to successfuly find column with user_id and prog_id I should pass two id's to accept method, but here I'm get stack. So, could I somehow pass two ids(user.id, @prog) at once from progs/show.html.erb?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900