Skip to content

Instantly share code, notes, and snippets.

@luizfonseca
Created July 21, 2011 17:18
Show Gist options
  • Save luizfonseca/1097672 to your computer and use it in GitHub Desktop.
Save luizfonseca/1097672 to your computer and use it in GitHub Desktop.
Better loading of styles on a Rails Application :-)
%h1 When using HAML, or even the rails .erb format, you can improve the loading of your pages using:
= stylesheet_link_tag controller.action_name
%span Or
= stylesheet_link_tag self.current_method
%span And create the proper CSS file in the public/style folder (e.g.: action_name.(s)css/ current_method.(s)css.
With this, the user only requests the CSS file from that page he is visiting.
@luizfonseca
Copy link
Author

  • Before it was:
= stylesheet_link_tag @controller.action_name

But the @controller.action_name is deprecated already. The following is the correct way to call it:

= stylesheet_link_tag controller.action_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment