[Rails-core] small extension to link_to_if

2013-12-17 Thread angelo capilleri
Hi I frequently use link_to in the context of conditional statement, What do you think about a link helper that return nil when the condition is false ex: # condtional = nil || false %= link_to_if conditional, an_url, allow_hide: true % # = nil or %= link_to_if! conditional, an_url % #

Re: [Rails-core] small extension to link_to_if

2013-12-17 Thread Luis Ferreira
You mean like these? http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_unless On 17 Dec 2013, at 14:43, angelo capilleri capill...@gmail.com wrote: Hi I frequently use link_to in the context of conditional

Re: [Rails-core] small extension to link_to_if

2013-12-17 Thread angelo capilleri
No, currently link_to_if(unless) returns the name in the false case. Il giorno martedì 17 dicembre 2013 15:52:57 UTC+1, Zamith ha scritto: You mean like these? http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if

Re: [Rails-core] small extension to link_to_if

2013-12-17 Thread Carlos Antonio da Silva
You can already achieve basically the same functionality with Ruby and conditional modifiers: %= link_to an_url,.. do % Menu Label for admin % end if user_role.admin? % %= link_to an_url,.. do % Menu Label for user % end if user_role.user? % %= link_to an_url,.. do % Menu Label for gues %

Re: [Rails-core] small extension to link_to_if

2013-12-17 Thread Rafael Mendonça França
Maybe would be better if you continue to do what you are doing or define a helper in your side. For your use case you may have a div that can’t be seem by a normal users, so link_to_if! will not help you, and I don’t see us adding content_for_if or form_tag_if inside Rails. Rafael Mendonça

Re: [Rails-core] small extension to link_to_if

2013-12-17 Thread Ruben Gil
What about using link_to_unless ? 2013/12/17 angelo capilleri capill...@gmail.com Hi I frequently use link_to in the context of conditional statement, What do you think about a link helper that return nil when the condition is false ex: # condtional = nil || false %= link_to_if

Re: [Rails-core] small extension to link_to_if

2013-12-17 Thread Tejas Dinkar
On 17-Dec-2013, at 9:11 pm, Carlos Antonio da Silva carlosantoniodasi...@gmail.com wrote: %= link_to an_url,.. do % Menu Label for admin % end if user_role.admin? % Although it doesn’t change things much, I would write this as: %= link_to “Menu Label for Admin”, a_url if user_role.admin? %