Question

I would like allow users to create groups and invite other users to their group. Currently, I have users and groups connected through has_many :through relationship (where Membership is the class that connects User and Group classes).

I am allowing the owner of the group to go to the "show" page for a group and create memberships by selecting users to invite (through a form). When I do this, I want to pass not only the ids of the users he selected but also the id of the group whose "show" page he is on.

What is the best way to accomplish this task? Currently, I am including a hidden tag in the form that includes the value @group.id. However, I imagine that there must be a better way to do this.

Was it helpful?

Solution

Just include it in the route that the form submits to, in the same way the show page is sending params[:id].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top