title: How to pass hidden parameter to controller in Rails3
body: <p>I'd like to pass the parameter <code>recipient</code> to controller. I can show it in my view like this:</p>
  
  <pre><code>@recipient.username
  </code></pre>
  
  <p>How can I pass this value to <code>params[:message][:recipient]</code>? Note that I do not have a model called "Message".</p>
  
  <p>controllers/messages_controller.rb</p>
  
  <pre><code>def deliver
    recipient = User.find_by_username(params[:recipient])
    subject = params[:subject]
    body = params[:body]
  
    current_user.send_message(recipient, body, subject)
    redirect_to :controller =&gt; 'messages', :action =&gt; 'received' 
    flash[:notice] = "message sent!"
  end
  </code></pre>
  
  <p>views/messages/new.html.erb</p>
  
  <pre><code>&lt;td&gt;&lt;%= @recipient.username if @recipient %&gt;&lt;/td&gt;
  
  &lt;%=form_for :messages, url: url_for( :controller =&gt; :messages, :action =&gt; :deliver ) do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :subject %&gt;&lt;br /&gt;
      &lt;%= f.text_field :subject %&gt;
    &lt;/div&gt; 
  
    &lt;div class="field"&gt;
      &lt;%= f.label :body %&gt;&lt;br /&gt;
      &lt;%= f.text_field :body %&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
  &lt;% end %&gt;
  </code></pre>