Browse files

Alert about the new Bundler require for asset gems

If you are coming from a Rails 3.0 application, you won't have
the correct Bundler require statement.

This will cause the gems under the `assets` group not to be available
in the development and production environment.

I think this is related to the issue #39 in rails-sass
  • Loading branch information...
nhocki authored and vijaydev committed Sep 26, 2011
1 parent e9de9e2 commit 0b151a49e0ac7df2c50c6b5b2bc0a09d41186fe3
Showing with 20 additions and 1 deletion.
  1. +20 −1 railties/guides/source/asset_pipeline.textile
@@ -249,9 +249,9 @@ h4. Preprocessing
The file extensions used on an asset determine what preprocessing is applied. When a controller or a scaffold is generated with the default Rails gemset, a CoffeeScript file and a SCSS file are generated in place of a regular JavaScript and CSS file. The example used before was a controller called "projects", which generated an +app/assets/javascripts/ and a +app/assets/stylesheets/projects.css.scss+ file.
When these files are requested, they are processed by the processors provided by the +coffee-script+ and +sass-rails+ gems and then sent back to the browser as JavaScript and CSS respectively.
Additional layers of pre-processing can be requested by adding other extensions, where each extension is processed in a right-to-left manner. These should be used in the order the processing should be applied. For example, a stylesheet called +app/assets/stylesheets/projects.css.scss.erb+ is first processed as ERB, then SCSS and finally served as CSS. The same applies to a JavaScript file -- +app/assets/javascripts/ is processed as ERB, CoffeeScript and served as JavaScript.
Keep in mind that the order of these pre-processors is important. For example, if you called your JavaScript file +app/assets/javascripts/ then it is processed with the CoffeeScript interpreter first, which wouldn't understand ERB and therefore you would run into problems.
h3. In Development
@@ -638,3 +638,22 @@ group :assets do
gem 'uglifier'
+If you use the +assets+ group with Bundler, please make sure that your +config/application.rb+ has the following Bundler require statement.
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require *Rails.groups(:assets => %w(development test))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+Instead of the old Rails 3.0 one
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)

0 comments on commit 0b151a4

Please sign in to comment.