Hello, I was wondering how I can control the navigation links in a layout to not show a link to the current page/action. I have a layout with a navigation area that has links to various actions. I do not want the link to the current page/action to be visible. I know I can create a different template for each actions - but how Un-DRY. So is there a way for the template to know which action/page we are on and then use that information to decide what to show - like in PHP? Code examples are always helpful. Thanks in advance --K *Please don''t just tell me to buy XXX book - I have them - at least tell me where to look --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I was wondering how I can control the navigation links in a layout to > not show a link to the current page/action. > > I have a layout with a navigation area that has links to various > actions. I do not want the link to the current page/action to be > visible. > I know I can create a different template for each actions - but how > Un-DRY. So is there a way for the template to know which action/page we > are on and then use that information to decide what to show - like in > PHP? Code examples are always helpful.check out http://api.rubyonrails.com/classes/ActionView/Helpers/UrlHelper.html#M000382 In views you can also use controller.controller_name, controller.action_name Regards, Rimantas -- http://rimantas.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I was wondering how I can control the navigation links in a layout to > not show a link to the current page/action. > > I have a layout with a navigation area that has links to various > actions. I do not want the link to the current page/action to be > visible. > I know I can create a different template for each actions - but how > Un-DRY. So is there a way for the template to know which action/page we > are on and then use that information to decide what to show - like in > PHP? Code examples are always helpful.link_to_unless_current(name, options = {}, html_options = {}, *parameters_for_method_reference, &block) Creates a link tag of the given name using an URL created by the set of options, unless the current request uri is the same as the links, in which case only the name is returned (or the given block is yielded, if one exists). This is useful for creating link bars where you dont want to link to the page currently being viewed. Or for more customization link_to_if or link_to_unless.... -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Beautiful. Thanks to all. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---