Unable to get Rails 3.1, Compass, Sass, Blueprint working on Heroku Cedar
For the most part I've followed the direction laid out here
Which is resulted in the following error coming from the initializer it asked me to create:
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)
The Heroku page on getting started isn't much help either. It is basically the same instructions only without the initializer. However without it, then it can't find any of the blueprint stuff so I still can't start.
Anyone out there who has made it further than I have?
Edit for more history:
I went through a number of errors to get here so I figured I should write them all out. The first problem I had was that html5-boilerplate was in :assets which meant that the ie_html method wasn't found, so I pulled that out of :assets.
This resulted in this error because html5-boilerplate depends on compass:
2011-09-05T17:15:47+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/bundler/gems/compass-b7f4开发者_JAVA百科4a48d375/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)>'
In the end the final solution was to also make sass-rails global (or at least it appears to have been). I sort of feel like I finally got this to work by co-incidence but here it is.
I pulled compass out of :assets and made it global too. Which then led to errors with compiling the SCSS files which finally led me to upgrade to Ceder which then resulted in the blueprint missing errors.
Lastly I added the initializer which, I assume, is meant to add the compass framework stuff to the config path. Hope that all helps.
Here is the relevant code:
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"
Note the github versions for compass and html5-boilerplate (you don't need h5bp if you don't use it).
The initializer is:
Rails.configuration.sass.tap do |config|
config.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
end
The issue isn't that sass-rails needs to be global, but that something in your global set relies on sass-rails.
For me, the solution was to move compass into the assets group.
I've put some detailed instructions up here: http://www.mattvanhorn.com/2012/01/07/heroku-cedar-assets-ruby-1-9/
It covers getting a basic Rails 3.1 app with Compass framework running on Heroku Cedar stack.
There are also links to a github repo ( http://github.com/mattvanhorn/placepanda/commits ) so you can follow along step-by-step with the commits.
You might need to also add load_paths in application.rb if you're using blueprint. I use twitter bootstrap on another app like this, and I've got:
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
in my application.rb, the conditional is to prevent Heroku from barfing on startup, when config.sass will no longer be available as it is for pre-compile.
精彩评论