You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jeffsu edited this page Mar 22, 2011
·
2 revisions
Setting up for Rails
Install JS2
Assuming you have a proper ruby, rails and gem setup, all you need to do to install JS2 is to include it in your Gemfile. Presumably, you want to compile your JS2 files in development mode and already have your target Javascript files checked in to your source control. If this is so, add this to your Gemfile:
group(:development) do
gem 'js2'
end
Otherwise, just put:
gem 'js2'
Now run:
bundle install
Plugin JS2 in development environment
At this point, you should have js2 installed. Now you can hook it into rails to compile automatically in development mode by adding JS2::Rack to your middleware. In ./config/environments/development.rb, add this line:
config.middleware.use JS2::Rack
Directories
By default JS2 will look in "app/js2" for your source files (anything with a js2 extension) and write normal javascript to "public/javascripts". You can change this by creating a "./config/js2.yml" file.