生产模式下是否有适用于 Rails 3.1 以及 Scss、Haml、Compass 和 HTML-Boilerplate 的有效 Gemfile?
我有一个成功的 Rails 3.0.x 项目,在 Gemfile 中包含以下 Gems 子集:
gem "compass"
gem "haml"
gem "haml-rails"
gem "html5-boilerplate"
今天我尝试升级到 Rails 3.1 并保留所有功能,但在这样做时遇到了很多问题。我还没有找到在生产模式下适合我的配置,所以我现在正在开发模式下工作。
我在这里遵循了以下建议:
- “升级到 Rails 3.1” 来自 Railscast:一如既往地非常好,并告诉我如何更改
development.rb
、development.rb
和application.rb
更新资产管道的配置。但没有接触 compass、sass 和 html5-boilerplate。 - "使用 Rails 3.1 设置 html-boilerplate"< /a> 其中包含最适合我的内容,但不起作用,因为方法
ie_html
在生产模式下不可用。 Gemfile 中的更改记录在 - “无法让 Rails 3.1、Compass、Sass、Blueprint 在 Heroku Cedar 上工作” 这对我来说根本不起作用,我当时编译的资产有问题。那里的尝试是使所有内容都全局化,因为 Compass 和 Html-Boilerplate 之间存在依赖关系,并且由于
ie_html
方法,Html-Boilerplate 必须是全局的。 - 每次尝试仅使用
group :assets
块中的一些 Gem 都没有成功。大多数时候,compass 和 sass、compass 和 html5-boilerplate 之间的依赖关系无法实现。
所以我的问题是:是否有一个有效的 Gemfile 允许一起使用 Haml、Sass、Compass、Html5-Boilerplate,当然还有 Rails 3.1?
新的 Gemfile 在开发模式下工作,但不在生产模式下工作:
gem "haml-rails"
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
gem 'compass', '~> 0.12.alpha.0'
gem "html5-boilerplate"
end
gem 'jquery-rails'
我尝试创建一个新的 Rails 3.1 应用程序,并在其中添加了图像资源。一切都工作正常,因此开发模式和生产模式没有区别。在我迁移的应用程序中,我现在处于以下状态:
- 在开发模式下运行良好。
- 禁用一些 html5-boilerplate 的东西来解决生产中的问题。
- 尚未找到生产模式下的预编译映像。
I have a successful Rails 3.0.x project with the following subset of Gems in the Gemfile:
gem "compass"
gem "haml"
gem "haml-rails"
gem "html5-boilerplate"
I tried today to upgrade to Rails 3.1 and keep all functionality, and had numerous problems in doing so. I did not yet find a configuration that did work for me in production mode, so I am working now with developing mode.
I followed the following advices here:
- "Upgrading to Rails 3.1" from Railscast: very good as usual, and told me how to change
production.rb
,development.rb
andapplication.rb
to update the configuration for the asset pipeline. But did not touch compass, sass, and html5-boilerplate. - "Setup html-boilerplate with Rails 3.1" That contained the best fit for me, but does not work, because the method
ie_html
is not available in production mode. The change in the Gemfile is noted down - "Unable to get Rails 3.1, Compass, Sass, Blueprint working on Heroku Cedar" This did not work for me at all, I had problems to the the assets compiled then. There the try was to have everything global, because there is a dependency between Compass and Html-Boilerplate, and Html-Boilerplate has to be global due to the method
ie_html
. - Every try to use only some the Gems in the
group :assets
block was not successful. Most of the time, the dependency between e.g. compass and sass, or compass and html5-boilerplate could not be fulfilled.
So my question is: Is there a working Gemfile which allows to use Haml, Sass, Compass, Html5-Boilerplate and of course Rails 3.1 together?
New Gemfile working in development mode, but not in production mode:
gem "haml-rails"
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
gem 'compass', '~> 0.12.alpha.0'
gem "html5-boilerplate"
end
gem 'jquery-rails'
I have tried to create a fresh Rails 3.1 application, and added there an image resource. There everything is working fine, so no difference between development mode and production mode. In my migrated application, I have now the following state:
- Works well in development mode.
- Disable some of the html5-boilerplate things to work around the problems in production.
- Does not find yet the precompiled images in production mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我让它在 Heroku Cedar 上工作。
但在 git push heroku 之前,首先在本地预编译:
然后将所有公共/资产添加到您的 git 存储库并提交。然后:
Heroku 将检测
public/assets/manifest.yml
文件并仅使用这些文件。这对我有用,所以应该有用!干杯
I have it working on Heroku Cedar.
But before
git push heroku
first precompile locally with:then add all public/assets to your git repo and commit. Then:
Heroku will detect the
public/assets/manifest.yml
file and just use these files.This works for me so should work! Cheers
只是为了包含一些其他人可能会有所帮助的信息,这里是我目前有效的情况(或多或少):
Gemfile
就像问题中定义的那样。production.rb
)解决了这个问题。我不会在这里投入更多时间,等待 Rails 3.1.1 和 html5-boilerplate 的更新。
Just to include some of the information that may others help, here my current situation that works (more or less):
Gemfile
like defined in the question.production.rb
which contained the wrong entry).I will not invest more time here, and wait for updates for Rails 3.1.1 and html5-boilerplate.
首先,我很抱歉添加另一个答案,但我认为历史对其他人有帮助。
我再次尝试(感谢@theanym的评论)使用rails 3.1.1、html5-boilerplate、compass、sass和haml创建一个新应用程序,并且我找到了一个适用于开发和生产模式的工作解决方案。
这些是我采取的步骤:
当我在生产模式下启动时,出现以下错误:
然后我更改了
Gemfile
(仅相关部分):对我来说,解决方案的相关部分是表示
compass
和html5-boilerplate
附加参数:group =>; :生产
。然后,我必须预编译资产,并且必须将
style.scss
更改为style.css.scss
,但这是一个小小的调整。在开发和生产模式下测试了该应用程序,似乎没有错误。First my apologies for adding another answer, but I think the history is helpful for others.
I tried again (thank's to the comment of @theanym) to create a new application with rails 3.1.1, html5-boilerplate, compass, sass and haml, and I found a working solution for development and production mode.
These are the steps I have taken:
When I started then in production mode, I got the following error:
I then changed the
Gemfile
(only the relevant part):The relevant part of the solution for me was to denote for
compass
andhtml5-boilerplate
that additional argument:group => :production
.I then had to precompile the assets, and had to change
style.scss
tostyle.css.scss
, but that was a minor tweak. Tested the application both with development and production mode, and there seems to be no error.