instead of link_to, use link_to_unless_current
this will still display the text, but it won''t be a link. If you want
the text to be hidden, you could write your own method to do it.
I would look at the source for link_to_unless
172: def link_to_unless(condition, name, options = {}, html_options = {},
*parameters_for_method_reference, &block)
173: if condition
174: if block_given?
175: block.arity <= 1 ? yield(name) : yield(name, options,
html_options, *parameters_for_method_reference)
176: else
177: name
178: end
179: else
180: link_to(name, options, html_options,
*parameters_for_method_reference)
181: end
182: end
and link_to_unless_current
166: def link_to_unless_current(name, options = {}, html_options = {},
*parameters_for_method_reference, &block)
167: link_to_unless current_page?(options), name, options, html_options,
*parameters_for_method_reference, &block
168: end
Naga harish Kanegolla wrote:>
> Hi all,
> Is there any way of doing Navigation using Rails. Such that if we are
> in controller "xyz" and action "abc", then we should
not get the link of
> "xyz" given in the layout. It should be hidden. I did this using
hard
> coding by writing if condition. But is there any other method to do
> this??
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---