在 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
...
这是否意味着这些 gem 现在将默认捆绑在生产版本中?如果是这样,为什么会改变主意?Rails 4 是否正在朝着在生产环境中动态生成资产的方向发展?