More Rails Features

Flashcard 8 of 8

How could we expose the current Rails environment to our application.js manifest file?

The asset pipeline can process any number of file extensions, starting from the last, and moving in until it reaches an output format. Knowing this, we can rename our application.js to application.js.erb and use erb interpolation to specify the Rails env:

//= require jquery
//= require jquery-ujs

window.App = {
  environment: "<%= Rails.env %>"
}
Return to Flashcard Results