无法获得在Heroku Cedar上工作的Rails 3.1,Compass,Sass,Blueprint

时间:2011-09-05 17:12:36

标签: ruby-on-rails heroku ruby-on-rails-3.1

在大多数情况下,我遵循了here

所列出的方向

导致以下错误来自它要求我创建的初始化程序:

from /app/config/initializers/sass.rb:1:in `<top (required)>'
2011-09-05T16:45:42+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-    3.1.0/lib/rails/railtie/configuration.rb:78:in `method_missing': undefined method `sass' for #  <Rails::Application::Configuration:0x00000003845528> (NoMethodError)

入门的Heroku页面也没什么帮助。只有没有初始化程序,它基本上是相同的指令。但是没有它,那么它找不到任何蓝图的东西,所以我仍然无法启动。

那里的人比我更进一步了吗?

修改更多历史记录:

我经历了一些错误到达这里,所以我想我应该全力以赴。我遇到的第一个问题是html5-boilerplate在:assets表示没有找到ie_html方法,所以我把它拉出来:资产。

这导致了这个错误,因为html5-boilerplate依赖于指南针:

2011-09-05T17:15:47+00:00 app[web.1]:    /app/vendor/bundle/ruby/1.9.1/bundler/gems/compass-b7f44a48d375/lib/compass/version.rb:56:in   `const_missing': uninitialized constant Compass::Frameworks (NameError)
2011-09-05T17:15:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bundler/gems/compass-html5-boilerplate-405f9ddbca56/lib/html5-boilerplate.rb:1:in `<top (required)>'

3 个答案:

答案 0 :(得分:9)

最后,最终的解决方案是让sass-rails全球化(或者至少它似乎已经存在)。我有点觉得我终于通过共同发生来实现这一点,但现在就是这样。

我把指南针拉出来:资产并使其成为全球性的。这导致编译SCSS文件时出错,最终导致我升级到Ceder,导致蓝图丢失错误。

最后我添加了初始化程序,我认为这是为了将指南针框架内容添加到配置路径中。希望一切都有所帮助。

以下是相关代码:

gem 'heroku'
gem 'haml'
gem 'compass', :git => 'git://github.com/chriseppstein/compass.git'
gem 'html5-boilerplate', :git => 'git://github.com/sporkd/compass-html5-boilerplate.git'
gem 'sass-rails', "  ~> 3.1.0"

请注意罗盘和html5样板的github版本(如果不使用它,则不需要h5bp。)

初始化程序是:

Rails.configuration.sass.tap do |config|
  config.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
end

答案 1 :(得分:1)

问题不在于sass-rails需要是全局的,而是全局集中的某些内容依赖于sass-rails。

对我来说,解决方案是将罗盘移入资产组。

答案 2 :(得分:0)

我在这里写了一些详细的说明: http://www.mattvanhorn.com/2012/01/07/heroku-cedar-assets-ruby-1-9/

它包括使用在Heroku Cedar堆栈上运行的Compass框架获取基本的Rails 3.1应用程序。

还有指向github仓库(http://github.com/mattvanhorn/placepanda/commits)的链接,因此您可以按照提交的步骤进行操作。

如果您正在使用蓝图,则可能还需要在application.rb中添加load_paths。我在另一个这样的app上使用twitter bootstrap,我得到了:

if Rails.configuration.respond_to?(:sass)
  config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
  config.sass.load_paths << "#{Gem.loaded_specs['compass_twitter_bootstrap'].full_gem_path}/lib/../stylesheets"
end

在我的application.rb中,条件是防止Heroku在启动时被禁止,当config.sass将不再可用时进行预编译。