Bizt
2014-Feb-02 06:22 UTC
Best practise for setting default URL parameters in the controller
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 practise is for
handling this. Thanks
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/b28b477a-bbfe-4b78-9592-e08cba2484f7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.