... # 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
现在,根据(仍在进行中)upgrade documentation:
Rails 4.0 removed the assets group from Gemfile. You’d need to remove that line from your Gemfile when upgrading.
果然,使用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是否朝着动态生成资产的方向发展?
这在the commit中有更详细的解释,改变了。我提取了一些报价与实际的答案。
Some gems can be needed (in production) like coffee-rails if you are using coffee templates
and the fact that now assets are not precompiled on demand in production anymore.(not precompiled on demand in production) Means that if you have that gems in production environment in 3.2.x and forget to precompile,Rails will do exactly what it does in development,precompile the assets that was requested. This is not true anymore in Rails 4,so if you don’t precompile the assets using the tasks you will get a 404 when the assets are requests.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。