[ rails ] link_to_if

Syntax

link_to_if(condition is true, name, options = {}, html_options = {}, &block)

NOTE : if condition is true, otherwise only the name is returned

link_to_if(it_has_link?, "text to show", "http://google.com", target: '_blank', rel: "http://whatever/rel/url")

ref : http://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/UrlHelper.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s