在Heroku部署rails app时无法识别CSS

时间:2013-09-13 20:30:51

标签: css ruby-on-rails heroku

我知道这个问题已经被问到overovereven here ......我已经尝试了所有这些变化,但仍然没有这样的运气。我的heroku app住在http://calm-mountain-2401.herokuapp.com/,我对此感到非常沮丧。我的gemfile看起来像:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

group :production do
  gem 'pg'
end
group :development, :test do
  gem 'sqlite3'
end

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more:      https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'


gem 'jquery-turbolinks'


group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

我已经能够成功部署,但代码显然不是CSS-ified。任何帮助将不胜感激!

亚历

编辑:这是git push heroku master的输出

$ git push heroku master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 496 bytes, done.
Total 5 (delta 3), reused 0 (delta 0)

-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --  binstubs vendor/bundle/bin --deployment
       Using rake (10.1.0)
       Using i18n (0.6.5)
       Using minitest (4.7.5)
       Using multi_json (1.8.0)
       Using atomic (1.1.14)
       Using thread_safe (0.1.3)
       Using tzinfo (0.3.37)
       Using activesupport (4.0.0)
       Using builder (3.1.4)
       Using erubis (2.7.0)
       Using rack (1.5.2)
       Using rack-test (0.6.2)
       Using actionpack (4.0.0)
       Using mime-types (1.25)
       Using polyglot (0.3.3)
       Using treetop (1.4.15)
       Using mail (2.5.4)
       Using actionmailer (4.0.0)
       Using activemodel (4.0.0)
       Using activerecord-deprecated_finders (1.0.3)
       Using arel (4.0.0)
       Using activerecord (4.0.0)
       Using coffee-script-source (1.6.3)
       Using execjs (2.0.1)
       Using coffee-script (2.2.0)
       Using thor (0.18.1)
       Using railties (4.0.0)
       Using coffee-rails (4.0.0)
       Using hike (1.2.3)
       Using jbuilder (1.5.1)
       Using jquery-rails (3.0.4)
       Using turbolinks (1.3.0)
       Using jquery-turbolinks (2.0.1)
       Using json (1.8.0)
       Using pg (0.16.0)
       Using bundler (1.3.2)
       Using tilt (1.4.1)
       Using sprockets (2.10.0)
       Using sprockets-rails (2.0.0)
       Using rails (4.0.0)
       Using rdoc (3.12.2)
       Using sass (3.2.10)
       Using sass-rails (4.0.0)
       Using sdoc (0.3.20)
       Using uglifier (2.2.1)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Detected manifest file, assuming assets were compiled locally
-----> WARNINGS:
       Include 'rails_12factor' gem to enable all platform features
       See https://devcenter.heroku.com/articles/rails-integration-gems for more information.

       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.0.0'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker

-----> Compiled slug size: 38.5MB
-----> Launching... done, v8
       http://calm-mountain-2401.herokuapp.com deployed to Heroku

To git@heroku.com:calm-mountain-2401.git
   6e49406..83bf74d  master -> master`

2 个答案:

答案 0 :(得分:0)

您是否尝试过明确预编译资产?

heroku run bundle exec rake assets:precompile

答案 1 :(得分:0)

对我来说,是pdoherty926的解决方案。

尝试添加rails_12factor和rails3_serve_static_assets(我知道你不是使用Rails 3)的宝石。