Rails 4,资产编译

我可能浪费了4个小时试图让这个问题消失,不知道问题是什么。

本地我一直在创建我的Rails应用程序,所有资产都正确加载,可以在这里看到:

                              

所以,酷它在开发模式下工作……但是当我推送到heroku时它不起作用!

 BuyABrick      

当我点击

  

服务器返回给我一个内部服务器错误( 编辑没有意识到HTML搞砸了一切)

在此处输入图像描述

因此,我通过研究互联网来尝试所有人的灵魂。 这是我有的文件……

配置/环境/ production.rb

 BuyABrick::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 = true # 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 = true # 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 = "nill" # 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( application.css) # 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 end 

任何帮助将不胜感激..如果你想要更多的代码看看我的github ..

https://github.com/srizzling/BuyABrick

谢谢!

Heroku记录

 $ heroku logs 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T12:54:31.548606+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T12:54:31.548787+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T12:54:31.548787+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T12:54:31.574177+00:00 heroku[router]: at=info method=GET path=/assets/application-6aa3a38ecf886de2bf443a2b4b67ab04.js host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=3ms service=24ms status=500 bytes=334 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T12:54:31.571790+00:00 app[web.1]: [2013-09-16 12:54:31] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T12:54:31.571790+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T12:54:31.571970+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T12:54:31.571970+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T12:54:31.553228+00:00 heroku[router]: at=info method=GET path=/assets/application-5c6e8eba841451fd8e44660093bd224e.css host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=3ms service=9ms status=500 bytes=334 2013-09-16T12:54:31.885143+00:00 app[web.1]: [2013-09-16 12:54:31] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T12:54:31.885290+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T12:54:31.885290+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T12:54:31.885143+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T12:54:31.892947+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=2ms service=17ms status=500 bytes=334 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T12:54:35.755436+00:00 app[web.1]: [2013-09-16 12:54:35] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T12:54:35.755436+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T12:54:35.755629+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T12:54:35.755629+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T12:54:35.757107+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=2ms service=10ms status=500 bytes=334 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T12:54:43.891290+00:00 app[web.1]: [2013-09-16 12:54:43] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T12:54:43.891290+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T12:54:43.891475+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T12:54:43.891475+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T12:54:43.895919+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=29ms service=8ms status=500 bytes=334 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T12:56:14.421956+00:00 app[web.1]: [2013-09-16 12:56:14] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T12:56:14.421956+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T12:56:14.422129+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T12:56:14.422129+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T12:56:14.423497+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=1ms service=5ms status=500 bytes=334 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T13:00:55.666613+00:00 app[web.1]: [2013-09-16 13:00:55] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T13:00:55.666613+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T13:00:55.666801+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T13:00:55.666801+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T13:00:56.096391+00:00 app[web.1]: [2013-09-16 13:00:56] ERROR ArgumentError: wrong number of arguments (0 for 1) 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:140:in `variation' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:133:in `call' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/ssl.rb:24:in `call' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-09-16T13:00:56.096391+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2013-09-16T13:00:56.096581+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2013-09-16T13:00:56.096581+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2013-09-16T13:00:56.100801+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=59ms service=7ms status=500 bytes=334 2013-09-16T13:00:55.669488+00:00 heroku[router]: at=info method=GET path=/assets/application-5c6e8eba841451fd8e44660093bd224e.css host=buyabrickonline.herokuapp.com fwd="115.188.114.182" dyno=web.1 connect=2ms service=5ms status=500 bytes=334 

Webrick把错误搞砸了

在此处输入图像描述

好的..上面这个问题与我的SSL配置有关…修复了现在的问题是……

在此处输入图像描述

所以我克隆了你的回购并在当地玩了一下,这是我采取的步骤让它发挥作用。

production.rb

注释掉这一行,因为在其他方面似乎没有必要

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

也注释了这一行

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

还有这个

  # Specifies the header that your server uses for sending files. #config.action_dispatch.x_sendfile_header = "nill" # for apache 

RAILS_ENV=production rails s现在似乎工作正常。

我还通过运行rake assets:clobber删除了预编译资产rake assets:clobber ,我发现在重度开发过程中让Heroku更容易进行预编译,因为我发现在推送到Heroku之前很容易忘记预编译并添加到git中…

希望这可以帮助。

您需要运行以下命令来预编译资产:

 heroku run bundle exec rake assets:precompile