Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the :assets group in rails 3.1 handled by bundler?

I don't understand what exactly is going on with this group, and what bundler is doing with it. Is it only loaded in dev mode? What if I want to make a new environment type, how should I handle this group? Etc.

group :assets do
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end
like image 424
jshen Avatar asked Sep 08 '11 16:09

jshen


People also ask

What is assets pipeline in rails?

1 What is the Asset Pipeline? The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

How do you Precompile rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What does rake assets Clean do?

rake assets:clean Only removes old assets (keeps the most recent 3 copies) from public/assets . Useful when doing rolling deploys that may still be serving old assets while the new ones are being compiled.

What are rails sprockets?

Sprockets is a crucial Ruby library that is used to serve and compile web assets. However, in Rails 7.0 the library becomes an optional dependency unless the application needs to use Sprockets. In such situations, the sprockets-rails gem will have to be added to the Gemfile .


1 Answers

The code that handles :assets group placed in config\application.rb. In rails 3.1 it is:

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)
end
like image 194
Dmitry Maksimov Avatar answered Dec 07 '22 04:12

Dmitry Maksimov