在Rails 3中,将专门用于在资产管道中生成资产的gem正确放置在assets
Gemfile组中:
...
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
end
现在,根据(仍在进行中的)升级文档:
Rails 4.0从Gemfile中删除了资产组。升级时,您需要从Gemfile中删除该行。
当然,使用RC1进行新项目会产生一个Gemfile,其中默认包含任何组以外的资产相关的gem:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0.rc1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
...
这是否意味着这些宝石现在将默认捆绑在生产版本中?如果是这样,为什么会改变主意?Rails 4是否正在朝着生产中动态生成资产的方向迈进?
RAILS_GROUPS=assets
(请参阅Rails.groups
参考资料)以在构建环境中预编译生产中的资产。