views:

25

answers:

2

I'm trying to do something like so:

link_to_unless_current "Inbox", messages_path(:inbox => true)

But, it seems that link_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?

+1  A: 

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")
Hugo
Thanks Hugo! I tried with :inbox => 1, but that still didn't seem to work for me". I tried it with "true" like Mark mentioned, and it works. Thanks for the help though!
sjsc
Ah well, good to know that then.
Hugo
+2  A: 

How about:

link_to_unless_current "Inbox", messages_path(:inbox => "true")
mark
Thanks Mark! Works great! Appreciate the help :)
sjsc