0

In order to easily distinguish between production and staging web site, I would like to apply different CSS styles, based on the Rails environment.

What is the best way to accomplish this please?

3
  • 1
    It's a very, very bad way to distinguish prod and staging site. Ideally, your staging server should work in the prod env Commented Jan 7, 2019 at 13:29
  • Thank you for your feedback. Can you please elaborate, why it is a bad practice? Commented Feb 19, 2019 at 18:59
  • Staging is commonly used to pre-check app functionality before deploy to prod. You can't be completely sure that your css works well if it differs on staging and prod Commented Feb 20, 2019 at 2:55

1 Answer 1

1

You can use Rails.env.production? and add some class to div, body etc... If you want to do it global in you application layout add something like:

<!-- application_layout -->
<body class="<%= Rails.env.production? ? 'prod-class' : 'dev-class' %>">
</body>

If is only for some div or element:

<div class="<%= Rails.env.production? ? 'prod-class' : 'dev-class' %>">
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

Or you can use Rails.env.staging? in the same way
Thank you, that helped.

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.