Chris.

That is good stuff, man. I like that third param/condition.  I've been using link_to_unless_current, but it doesn't keep the tab highlighted in any other actions.

Thanks!

-Nathan

Chris Abad wrote:
with the example I gave, the named route works as well (no hash necessary). so for this example, you'd do this:

navigation_link_to 'Home', home_path, (controller.controller_name == 'home')

This would give your "home" link an active class for all actions in the home controller.

On Feb 22, 2007, at 11:21 PM, Nick Zadrozny wrote:

On 2/22/07, Chris Abad <[EMAIL PROTECTED]> wrote:
one more thing. if you're trying to match the controller name, this is a bit
easier:
controller.controller_name == 'main'

In addition to all the great advice above in this thread, I will also
say that this is a handy place to use named routes.

Consider:
map.home '', :controller => 'main', :action ="" 'show'

Not only can you call something like <%= link_to 'Home', home_path %>
but you can also use the perhaps-lesser-known hash_for_home_path. A
call to hash_for_home_path as defined above would return just what you
expect:
{:controller=>"main", :action="">

If your helper is smart enough (and your IA simple enough), you could
conceivably have a call that looks like this:

navigation_link_to "Home", hash_for_home_path

Those hash_for methods should save some characters, not to mention
some time spent thinking up what belongs in those hashes, and your
helper still gets to work with a hash.

-- 
_______________________________________________
Sdruby mailing list


_______________________________________________ Sdruby mailing list [email protected] http://lists.sdruby.com/mailman/listinfo/sdruby



_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to