Navigation

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??

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