1

I have a multi-tenancy Rails app, where each tenant has an base_color attribute which contains a hex color code. I have a variables.css.scss file which contains Sass variables which are used in several other stylesheet files.

Now I want to use the tenant.base_color variable to set the Sass variable $base_color in variables.css.scss, so the base color of the app changes according to the logged in tenant. Is this at all possible?

I tried to rename the file to variables.css.scss.erb and then use this:

$base-color: <%= current_tenant.base_color %>;

But this doesn't work, I get an File to import not found or unreadable: variables.css.scss. error.

2
  • It's not possible. css.scss files are compiled to css once (when you run bundle exec rake assets:precompile), so you can't make them dependant on some dynamic values. I guess you'd have to use inline css instead. Commented Apr 9, 2014 at 10:44
  • That's a pity, but now it works by doing this. Can you move this as answer, then I'll give you credit. Commented Apr 10, 2014 at 6:02

1 Answer 1

1

It's not possible. css.scss files are compiled to css once (when you run bundle exec rake assets:precompile), so you can't make them dependant on some dynamic values. I guess you'd have to use inline css instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.