Ruby on Rails: How do you make link_to_unless_current work with parameters?
I'm trying to do something like so:
link_to_unless_current "Inbox", messages_path(:inbox => true)
But, it seems that l开发者_如何学运维ink_to_unless_current only works if I go to "http://localhost/messages" and not "http://localhost/messages?inbox=true" (i.e. it doesn't give a link for the latter which is correct, but it does for the former which is incorrect).
Any ideas on how to make:
link_to_unless_current "Inbox", messages_path(:inbox => true)
work correctly?
How about:
link_to_unless_current "Inbox", messages_path(:inbox => "true")
I'm not 100% sure (and I definitely would like to hear why) but I think if you try to pass in a boolean parameter that is true it gets ignored you need either a false boolean or any other things.
link_to_unless_current "Inbox", messages_path(:inbox => 1)
Or you could use routes
match "/messages/:folder" => "messages#index", :as => :messages_folder
and then
link_to_unless_current "Inbox", messages_folder_url(:folder => "Inbox")
精彩评论