Ruby 2.0 + Rails 4.0.0.RC1 + bootstrap + Heroku

时间:2013-06-05 15:37:54

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

刚开始使用新应用,想尝试使用Rails 4.0.0.RC1

在阅读了关于该主题的一些迁移教程之后,我让应用程序使用Ruby 2.0,Rails 4.0.0.RC1,Bootstrap with Sass,Devise ...以及一些自定义sass样式表进行开发。

今天我尝试部署到Heroku。该应用程序有效,但我的资产有问题。没有应用样式(也不显示图像)。

当我部署时,我可以在日志中看到资产是预编译的,但是当我启动应用程序时,它们没有被加载。我收到以下错误:

013-06-05T15:25:14.874303+00:00 heroku[router]: at=info method=GET path=/assets/logo-c580c24dad2871fc6515842fd30b1e92.png host=finanty-staging.herokuapp.com fwd="83.63.156.134" dyno=web.1 connect=0ms service=4ms status=404 bytes=1351
2013-06-05T15:25:14.883538+00:00 heroku[router]: at=info method=GET path=/assets/banner-25f5a47ec97eb21c636d94a061c3ec34.png host=finanty-staging.herokuapp.com fwd="83.63.156.134" dyno=web.1 connect=0ms service=4ms status=404 bytes=1351
2013-06-05T15:25:15.009161+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=finanty-staging.herokuapp.com fwd="83.63.156.134" dyno=web.1 connect=0ms service=4ms status=404 bytes=1351
2013-06-05T15:25:15+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2013-06-05T15:25:14.751092+00:00 heroku[router]: at=info method=GET path=/assets/application-8d76cba6ab1b7263edea41a06d7729ce.js host=finanty-staging.herokuapp.com fwd="83.63.156.134" dyno=web.1 connect=0ms service=4ms status=404 bytes=1351

我已经搜索了问题并尝试了一些我没有成功的解决方案。 已经尝试过预编译资产并包含Heroku的宝石:     gem'rail_log_stdout',github:'heroku / rails_log_stdout'     gem'rail3_serve_static_assets',github:'heroku / rails3_serve_static_assets'

有什么建议吗?

这是我目前的宝石文件:

source 'https://rubygems.org'
ruby "2.0.0"
gem 'rails', '4.0.0.rc1'
gem 'sass-rails', '~> 4.0.0.rc1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.4.1'
gem "cancan", "~> 1.6"
gem "rolify",        :git => "git://github.com/EppO/rolify.git"
gem "devise", "~> 3.0.0.rc"
gem "bootstrap-sass", "~> 2.3.1.2"
gem "font-awesome-sass-rails", "~> 3.0.2.2"
gem "simple_form", "~> 3.0.0.rc"
gem "figaro", "~> 0.6.4"
gem "haml-rails", "~> 0.4"

group :test do
  gem "capybara", "~> 2.1.0"
  gem "capybara-email", "~> 2.1.0"
  gem "database_cleaner", "~> 1.0.1"
  gem "email_spec", "~> 1.4.0"
  gem "shoulda-matchers", "~> 2.1.0"
end
group :development do
  gem "better_errors", "~> 0.9.0"
  gem "html2haml", "~> 1.0.1"
  gem "letter_opener", "~> 1.1.1"
  gem "quiet_assets", "~> 1.0.2"
end
group :test, :development do
  gem "rspec-rails", "~> 2.13.2"
  gem "fabrication", "~> 2.7.1"
  gem "faker", "~> 1.1.2"
  gem "pry", "~> 0.9.12.2"
  gem "pry-nav", "~> 0.2.3"
  gem "binding_of_caller", "~> 0.7.1"
  gem "sqlite3"
end
group :production do
  gem "unicorn", "~> 4.6.2"
  gem "pg", "~> 0.15.1"
  gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'
  gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'
end
group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

###更新HEROKU OUTPUTLOG和ENVIROMENT文件

HEROKU OUTPUT

[abibiano:~/Development/finanty (master)]$ git push staging master > ~\heroku.log
Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 377 bytes, done.
Total 4 (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.0.4)
       Using i18n (0.6.4)
       Using minitest (4.7.4)
       Using multi_json (1.7.4)
       Using atomic (1.1.9)
       Using thread_safe (0.1.0)
       Using tzinfo (0.3.37)
       Using activesupport (4.0.0.rc1)
       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.rc1)
       Using mime-types (1.23)
       Using polyglot (0.3.3)
       Using treetop (1.4.12)
       Using mail (2.5.4)
       Using actionmailer (4.0.0.rc1)
       Using activemodel (4.0.0.rc1)
       Using activerecord-deprecated_finders (1.0.2)
       Using arel (4.0.0)
       Using activerecord (4.0.0.rc1)
       Using bcrypt-ruby (3.0.1)
       Using sass (3.2.9)
       Using bootstrap-sass (2.3.1.2)
       Using cancan (1.6.10)
       Using coffee-script-source (1.6.2)
       Using execjs (1.4.0)
       Using coffee-script (2.2.0)
       Using thor (0.18.1)
       Using railties (4.0.0.rc1)
       Using coffee-rails (4.0.0)
       Using orm_adapter (0.4.0)
       Using warden (1.2.1)
       Using devise (3.0.0.rc)
       Using bundler (1.3.2)
       Using hike (1.2.2)
       Using tilt (1.4.1)
       Using sprockets (2.10.0)
       Using sprockets-rails (2.0.0.rc4)
       Using rails (4.0.0.rc1)
       Using figaro (0.6.4)
       Using sass-rails (4.0.0.rc1)
       Using font-awesome-sass-rails (3.0.2.2)
       Using haml (4.0.2)
       Using haml-rails (0.4)
       Using jbuilder (1.4.1)
       Using jquery-rails (2.2.1)
       Using json (1.8.0)
       Using kgio (2.8.0)
       Using pg (0.15.1)
       Using rails3_serve_static_assets (0.0.1) from git://github.com/heroku/rails3_serve_static_assets.git (at master)
       Using rails_log_stdout (0.0.1) from git://github.com/heroku/rails_log_stdout.git (at master)
       Using raindrops (0.11.0)
       Using rdoc (3.12.2)
       Using rolify (3.3.0.rc4) from git://github.com/EppO/rolify.git (at master)
       Using sdoc (0.3.20)
       Using simple_form (3.0.0.rc)
       Using turbolinks (1.1.1)
       Using uglifier (2.1.0)
       Using unicorn (4.6.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       I, [2013-06-06T07:37:16.836153 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/Apache License Version 2-4fbe59582e5aad1a405d789396ca29ac.txt
       I, [2013-06-06T07:37:16.841645 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Bold-webfont-fdb9ade201b65c0d52fa604fc3c4038d.eot
       I, [2013-06-06T07:37:17.173555 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Bold-webfont-2fa0527e93e9cb49943caec3f494fda6.svg
       I, [2013-06-06T07:37:18.715411 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Bold-webfont-b60a3804cef46ca9126b948bf7c7abdd.ttf
       I, [2013-06-06T07:37:22.979737 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Bold-webfont-a10f60b9bfead198bafcadc407d7ea45.woff
       I, [2013-06-06T07:37:24.726840 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-BoldItalic-webfont-99427976b80607502900b30c83fc15cc.eot
       I, [2013-06-06T07:37:26.398061 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-BoldItalic-webfont-b6866087b55f4d355807e4a6ba9a67b6.svg
       I, [2013-06-06T07:37:27.138720 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-BoldItalic-webfont-02efeadc2bf66c0699e61f698a531fbe.ttf
       I, [2013-06-06T07:37:27.327672 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-BoldItalic-webfont-8fae2aa8680e75ab0f9e8098f77b22c1.woff
       I, [2013-06-06T07:37:29.476265 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBold-webfont-24a94c91ee62eb693997964f849b775c.eot
       I, [2013-06-06T07:37:33.101954 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBold-webfont-98cbd2403d0d075a76b10aadcfd64362.svg
       I, [2013-06-06T07:37:33.915024 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBold-webfont-5f24d69329e91023a639e47dcb0ca732.ttf
       I, [2013-06-06T07:37:35.001425 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBold-webfont-43e2e4472be04c8df6eca1c043d293fe.woff
       I, [2013-06-06T07:37:37.723927 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBoldItalic-webfont-dd7801590c36df39cec7852cd3338a3a.eot
       I, [2013-06-06T07:37:40.125985 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBoldItalic-webfont-9e549205a163455b6cb10f8c015adde7.svg
       I, [2013-06-06T07:37:44.629199 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBoldItalic-webfont-9d7f7302bad42da4f2bf920a1d0e58b8.ttf
       I, [2013-06-06T07:37:45.603731 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-ExtraBoldItalic-webfont-2bd51857319d9ca71388686b298606c4.woff
       I, [2013-06-06T07:37:49.745637 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Italic-webfont-47a948e0b3ff9728d9335417ad999943.eot
       I, [2013-06-06T07:37:49.999723 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Italic-webfont-b202837471fc4c196a6f3dafff1cd0d3.svg
       I, [2013-06-06T07:37:50.132504 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Italic-webfont-c8441dbfa5423fd682fbe7bf78cd5cca.ttf
       I, [2013-06-06T07:37:50.317687 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Italic-webfont-d603a0227d2b76009c08db1073beb173.woff
       I, [2013-06-06T07:37:50.578619 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Light-webfont-39498b2896a3e99791adae2a92c6fb92.eot
       I, [2013-06-06T07:37:50.694793 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Light-webfont-082e59aa8e5531ababdb759127064b22.svg
       I, [2013-06-06T07:37:51.034404 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Light-webfont-2c4c3a429426b226b95ace57356b8d45.ttf
       I, [2013-06-06T07:37:51.402217 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Light-webfont-cdcecd01d9ab57d6b6f85139a55470be.woff
       I, [2013-06-06T07:37:51.622895 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-LightItalic-webfont-9c9abd2141528c54eb5debfea82a9640.eot
       I, [2013-06-06T07:37:51.846528 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-LightItalic-webfont-3935e471fb1fab8e4f122e33ee73614b.svg
       I, [2013-06-06T07:37:52.124299 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-LightItalic-webfont-2c42486a6c1927f94f1ba17cc9158fc2.ttf
       I, [2013-06-06T07:37:52.507480 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-LightItalic-webfont-edffcb2690b2bdd5f7e0c91e3166a224.woff
       I, [2013-06-06T07:37:52.897211 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Regular-webfont-bd488806819ed5cb79ebbe415f8ec336.eot
       I, [2013-06-06T07:37:53.325478 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Regular-webfont-337edf5323c855c6df491ae12a830af6.svg
       I, [2013-06-06T07:37:53.488674 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Regular-webfont-66420351d48ae7a8a7fb448fd06fe740.ttf
       I, [2013-06-06T07:37:53.590615 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Regular-webfont-07366fdff682934bafef5962ea1f39a7.woff
       I, [2013-06-06T07:37:53.786816 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Semibold-webfont-8b84e74812ab41a0d4b304cb4d9c94c2.eot
       I, [2013-06-06T07:37:53.859293 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Semibold-webfont-94e6d7af3f7108e9b4eff8da8bd9487b.svg
       I, [2013-06-06T07:37:54.034925 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Semibold-webfont-e0f277ee3b359d387ac633dd3240b186.ttf
       I, [2013-06-06T07:37:55.748157 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-Semibold-webfont-35f0d886332d57fc5cc8a1c037f7af79.woff
       I, [2013-06-06T07:37:55.794748 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-SemiboldItalic-webfont-9ca3a1ca26a59a4109bb8ac8b967b218.eot
       I, [2013-06-06T07:37:56.285810 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-SemiboldItalic-webfont-3e58592ad30d17dacc42e3f37eed2ff9.svg
       I, [2013-06-06T07:37:56.453714 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-SemiboldItalic-webfont-02299aaa6af5b48ecd73d521887ac49f.ttf
       I, [2013-06-06T07:37:56.600516 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/open-sans/OpenSans-SemiboldItalic-webfont-fd03f53c3fb90ccc248bf7ddb842efa2.woff
       I, [2013-06-06T07:37:56.753131 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/banner-25f5a47ec97eb21c636d94a061c3ec34.png
       I, [2013-06-06T07:37:56.896181 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/finanty_logo_32-d17a2835fa9bd5b570f10c4550ea2ebf.png
       I, [2013-06-06T07:37:56.986165 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/logo-c580c24dad2871fc6515842fd30b1e92.png
       I, [2013-06-06T07:38:01.826635 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/application-8d76cba6ab1b7263edea41a06d7729ce.js
       I, [2013-06-06T07:38:05.842219 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/application-c070e38f0f10779f6b4b776c20186bac.css
       I, [2013-06-06T07:38:05.854846 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/FontAwesome-f9ff08ec61a1d49230dcc790375b5ed1.otf
       I, [2013-06-06T07:38:06.142316 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/fontawesome-webfont-870afe701dcdde804cfe997f73cec44c.eot
       I, [2013-06-06T07:38:06.225915 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/fontawesome-webfont-bacb333cfb37308468da2e57052b9bab.ttf
       I, [2013-06-06T07:38:06.618678 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/fontawesome-webfont-e70f92449ebfddada3d455eb44542655.woff
       I, [2013-06-06T07:38:06.826000 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/glyphicons-halflings-white-2fa53df59ca25ee50f59f971c0c9175d.png
       I, [2013-06-06T07:38:07.044590 #1452]  INFO -- : Writing /tmp/build_2yy5wby4xn137/public/assets/glyphicons-halflings-4e5b89324f1ac987ddf6835ef51f5fe9.png
       Asset precompilation completed (54.69s)
-----> Rails plugin injection
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker

-----> Compiled slug size: 38.0MB
-----> Launching... done, v18
       http://finanty-staging.herokuapp.com deployed to Heroku

To git@heroku.com:finanty-staging.git
   952b326..05c09af  master -> master

环境/ staging.rb

Finanty::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both thread web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
  # config.action_dispatch.rack_cache = true

  # Disable Rails's static asset server (Apache or nginx will already do this).
  config.serve_static_assets = false

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

  # Generate digests for assets URLs.
  config.assets.digest = true

  # Version of your assets, change this if you want to expire all your assets.
  config.assets.version = '1.0'

  # Specifies the header that your server uses for sending files.
  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # Set to :debug to see everything in the log.
  config.log_level = :info

  # Prepend all log lines with the following tags.
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups.
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production.
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  # config.action_controller.asset_host = "http://assets.example.com"

  # Precompile additional assets.
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
  # config.assets.precompile += %w( search.js )

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found).
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners.
  config.active_support.deprecation = :notify

  # Disable automatic flushing of the log to improve performance.
  # config.autoflush_log = false

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  config.action_mailer.delivery_method = :smtp

  config.action_mailer.smtp_settings = {
    port:           587,
    address:        'smtp.gmail.com',
    user_name:      ENV['GMAIL_USERNAME'],
    password:       ENV['GMAIL_PASSWORD'],
    domain:         'finanty.com',
    authentication: :plain,
    enable_starttls_auto: true,
  }
  config.action_mailer.default_url_options = {
    host: "finanty.com"
  }
end

module HttpBasicAuth
  module ActionController
    def self.include(ac)
      ac.send(:http_basic_authenticate_with, {name: ENV['STAGING_USERNAME'], password: ENV['STAGING_PASSWORD']})
    end
  end
end

ActionController::Base.send(:include, HttpBasicAuth::ActionController)

Heroku上的环境变量设置为暂存

1 个答案:

答案 0 :(得分:2)

如果你要添加这样的资产:

config.assets.precompile += %w( asset.js asset.css )

尝试将其从config / production.rb移至config / application.rb

这是我遇到的Rails错误。