4

Is it possible to access Rails.env inside Sass files?

I'm trying to do it like this:

$url: <%= Rails.env.production? ? '//foo.com' : '//localhost:3000' %>

@font-face {
  src: url("#{$url}/font/fontawesome-webfont.eot");
}

But this gives:

Invalid CSS after "$url:": expected expression (e.g. 1px, bold), was "<%= Rails.env.p..."

I've tried with different file extensions, like css.scss.erb etc, but no joy.

stephenmurdoch
  • 34,024
  • 29
  • 114
  • 189
  • possible duplicate of [Use Ruby/Rails variables inside SASS and LESS?](http://stackoverflow.com/questions/7653381/use-ruby-rails-variables-inside-sass-and-less) – FoamyGuy Jul 02 '12 at 00:54

1 Answers1

7

Make sure it is name.css.scss.erb

Also, here is a good answer https://stackoverflow.com/a/7653451/643500

Community
  • 1
  • 1
Sully
  • 14,672
  • 5
  • 54
  • 79