I am using a remote form for my show action to retrieve content based on the parameters passed by this form.
= form_tag modelname_path(@modelname), :id=>"select_content_form", :remote => true, :method => 'get' do = text_field_tag :content_type, params[:content_type], :id=>"select_content_type" = submit_tag "submit", :name => nil, :id=>"select_content_submit"
And I modify the contents in the controller as follows:
# 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"
My question is whether the above approach is the only one for which we can set default values ββfor parameters, or whether we can do it better. This works, but I would like to know if this is correct.
UPDATE Based on the assumption below, I used the following and got an error in the defaults.merge line:
defaults = {:content_type=>"type1"} params = defaults.merge(params) @content_type = params[:content_type]
rgoraya
source share