Search code examples
ruby-on-railsruby-on-rails-pluginsmessaging

Rails Message This User Button


I am using this http://github.com/professionalnerd/simple-private-messages plugin in rails and I am on a user page show.html.erb - User and I want to put a button there that, when clicked, goes to the current user's inbox and populates the field call "send to" with the "user" name.

How do I send that data along when the button is clicked?

<%= link_to image_tag('send_message_button.jpg', :title => 'send #{user} a message', :alt => 'send #{user} a message'), new_user_message_path(current_user), :class=>'messageuser' %>

This goes to the current_user's inbox. I want to send the "params[:user_id]" variable along with it so that I can then fill out the "send to" textbox in the inbox page with it. How do I send that params variable along with this button?


Solution

  • Use Following

    <%= link_to image_tag('send_message_button.jpg', 
         :title => 'send #{user} a message',
         :alt => 'send #{user} a message'),
         {:controller=>controller_name, :action=>action_name, :id=>your_id, :user_id=>params[:user_id]},  
         :class=>'messageuser' %>