How can I use Ruby/Rails variables inside Sass?

Solution 1:

You can add .erb extention to your .sass file and then add your variables just like in regular .erb file:

<%= APP_CONFIG[:yourkey] %>

More information:

  • http://guides.rubyonrails.org/asset_pipeline.html#preprocessing
  • http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
  • http://rwilcox.tumblr.com/post/9038701675/sass-variables-and-the-rails-3-1-asset-pipeline