I basically want to have the environment check done in javascript only, so I don’t have to litter my view files with Rails.env.production? checks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way to do this I believe is to set a javascript variable to the value of Rails.env and then add a method in
application.jsto check it. The best place is probably in your layout so inapp/views/layouts/my_layout.html.erbsomething like:Which you can then use in your javascript code.