About me

说啥呢 欢迎欢迎,热烈欢迎。。

安装 foundation 以及 解决 heroku 无样式

August 07, 2013

首先按照foundation官网http://foundation.zurb.com/docs/rails.html给出的步骤执行,

group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
# Add Foundation Here
gem 'compass-rails' # you need this or you get an err
gem 'zurb-foundation', '~> 4.0.0'
end
当前目录下执行rails g foundation:install ,然后 rails s

如果出现 Unsupported rails environment for compass 将 gem 'compass-rails' 改为 gem 'compass-rails', github: "milgner/compass-rails", branch: "rails4" 重新bundle。如果还有问题请参看:https://github.com/Compass/compass-rails/pull/59

接下来是heroku的样式问题。首先安装pg,这是heroku使用的数据库,gem ‘pg’,‘0.16.0’ ,如果遇到问题,请看我的另一篇文章:rails gem install pg

然后在部署到heroku的时候有一个warning:

WARNINGS:

Include "rails_12factor" gem to enable all platform features

See https://devcenter.heroku.com/articles/rails-integration-gems for more information.

我没当回事,结果我打包后的css文件和js文件都是空的,百思不得其解,后来经过大神指点才知道要装这个gem包,在gemfile中加入 gem ‘rails_12factor’,然后再部署就样式就有了。