Unable to get Rails 3.1, Compass, Sass, Blueprint working on Heroku Cedar

谁都会走 提交于 2019-12-03 15:56:54

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!