title: Rails 3: Controller params default value
body: <p>I am using a remote form_for for my show action to retrieve content based on the params passed by this form. </p>
  
  <pre><code>= form_tag  modelname_path(@modelname), :id=&gt;"select_content_form", :remote =&gt; true, :method =&gt; 'get' do               
    = text_field_tag :content_type, params[:content_type], :id=&gt;"select_content_type"
    = submit_tag "submit", :name =&gt; nil, :id=&gt;"select_content_submit"
  </code></pre>
  
  <p>And I alter the content in controller as follows:</p>
  
  <pre><code># Default params to "type1" for initial load
  if params[:content_type]
    @content_type = params[:content_type];
  else
    @content_type = "type1"
  end
  
  case @content_type
  
  when "type1"
    # get the content
    @model_content = ...
  
  when "type1"
    # get the content
    @model_content = ...
  </code></pre>
  
  <p>My question is, whether the above approach is the only we can set defaults for params or can we do it in a better manner. This works but I would like to know if this is the right approach. </p>
  
  <p><strong>UPDATE</strong>
  Based on the suggestion below, I used the following and got an error on defaults.merge line:</p>
  
  <pre><code>defaults = {:content_type=&gt;"type1"}
  params = defaults.merge(params)
  @content_type = params[:content_type]
  </code></pre>