Reputation: 42583
I have built a very simple internal messaging system inside my application, i want to add a link to each user profile page where the logged in user can click on the link to send the other user which profile they are viewing a message.
messages is nested under users, so new message page would be /users/1/messages/new
so i have: <%= link_to 'Send Message', new_user_message_path(current_user) %>
how can i add a params values to the link with the user id and name of of the user he/she is viewing (object is called @user
) so the href would look something like this: /users/1/messages/new?to_id=3&to_name=somename
Thanks
Upvotes: 1
Views: 758
Reputation: 83680
<%= link_to 'Send Message', new_user_message_path(current_user, :to_id => 3) %>
Upvotes: 4