I've been trying to set default URL parameters in the controller, which will also be used within the view. This is what I've got:
@params = params
defaults = { :date_from => '21/1/21014', :date_to => '21/2/21014', :data=>"Expense" }
if @params.any?
@params = defaults.merge(@params)
else
@params = defaults
end
.. seems messy, and doesn't work :( When params are present it still uses the default params. Not sure where it's going wrong and search on google yields many varieties. I know using default values in methods is something that I will repeat again so I was wondering what the best practice is for handling this.