js_tag and css_tag

Since quiet some time i fail to remember how to include javascript and css.

stylesheet_include_tag and javascript_link_tag or
javascript_tag and stylesheet_tag ???

Since im so pragmatig (read: forgetful+lazy) i came up with a simple solution:

#application_helper.rb
module ActionView::Helpers::AssetTagHelper
  alias js_tag javascript_include_tag
  alias css_tag stylesheet_link_tag
end

now it starts looking nice and clean ๐Ÿ™‚

    <%= js_tag 'ufo' %>
    <%= js_tag 'jquery.min.js' %>

2 thoughts on “js_tag and css_tag

  1. I think this may cause difficulties in code interpretation. In addition, this does not improve the software functionality, and this type of tag is used a few times (most times in the layout only). I do not think good idea increase code entropy in favor of readability, what do you think?

  2. i think it improves readability/writability(no need to think: need js -> use js_tag), but like all aliases it has the drawbacks you mentioned. So far all newcommers to our project have used js/css_tag without asking questions ๐Ÿ™‚

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