我在Mac 10.6.8上使用最新的Ruby(1.9.3)和Rails(4.0.0).
我试过的事情
在Rails 3.1.3 on Heroku: (No route matches [GET] “/assets/rails.png”)的答案之后,我添加了config / application.rb的代码,用于在生产中懒洋洋地编译资产:
if defined?(Bundler) # If you want your assets lazily compiled in production,use this line Bundler.require(:default,:assets,Rails.env) end
根据Rails production static files routing error的答案,我修改了production.rb,以确保静态资产被提供:
config.serve_static_assets = true
但我还是得到了404.我还能做些什么?
Heroku日志:
2013-05-31T16:39:41.675219+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 2013-05-31T16:39:41.675219+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `call' 2013-05-31T16:39:41.675219+00:00 app[web.1]: F,[2013-05-31T16:32:49.152450 #2] FATAL -- : 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `block in tagged' 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:25:in `tagged' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/static.rb:64:in `call' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `tagged' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-05-31T16:39:41.676016+00:00 app[web.1]: F,[2013-05-31T16:32:52.415675 #2] FATAL -- : 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-05-31T16:39:41.675777+00:00 app[web.1]: 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/engine.rb:511:in `call' 2013-05-31T16:39:41.675777+00:00 app[web.1]: 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `block in tagged' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/application.rb:96:in `call' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 2013-05-31T16:39:41.675513+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/cache/strategy/local_cache.rb:83:in `call' 2013-05-31T16:39:41.676016+00:00 app[web.1]: I,[2013-05-31T16:32:52.414612 #2] INFO -- : Started GET "/" for 67.244.94.162 at 2013-05-31 16:32:52 +0000 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `block in call' 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:38:in `call_app' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/static.rb:64:in `call' 2013-05-31T16:39:41.676016+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:25:in `tagged' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2013-05-31T16:39:41.675777+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' 2013-05-31T16:39:41.676016+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `tagged' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/application.rb:96:in `call' 2013-05-31T16:39:41.676490+00:00 app[web.1]: 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/cache/strategy/local_cache.rb:83:in `call' 2013-05-31T16:39:41.676490+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-05-31T16:39:41.676490+00:00 app[web.1]: 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-05-31T16:39:41.676490+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/engine.rb:511:in `call' 2013-05-31T16:39:41.676490+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' 2013-05-31T16:39:41.676490+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 2013-05-31T16:39:41.676253+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `call' 2013-05-31T16:39:41.676490+00:00 app[web.1]: I,[2013-05-31T16:38:42.543864 #2] INFO -- : Started GET "/" for 67.244.94.162 at 2013-05-31 16:38:42 +0000 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `call' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `tagged' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:38:in `call_app' 2013-05-31T16:39:41.676490+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `block in tagged' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:25:in `tagged' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' 2013-05-31T16:39:41.676490+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' 2013-05-31T16:39:41.676490+00:00 app[web.1]: F,[2013-05-31T16:38:42.544833 #2] FATAL -- : 2013-05-31T16:39:41.677196+00:00 app[web.1]: 2013-05-31T16:39:41.677196+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/cache/strategy/local_cache.rb:83:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' 2013-05-31T16:39:41.677196+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `block in tagged' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2013-05-31T16:39:41.677196+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 2013-05-31T16:39:41.677665+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/static.rb:64:in `call' 2013-05-31T16:39:41.677196+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:38:in `call_app' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/engine.rb:511:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-05-31T16:39:41.677196+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `block in call' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `call' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/engine.rb:511:in `call' 2013-05-31T16:39:41.677665+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/rack/logger.rb:21:in `block in call' 2013-05-31T16:39:41.676725+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' 2013-05-31T16:39:41.677196+00:00 app[web.1]: 2013-05-31T16:39:41.677196+00:00 app[web.1]: I,[2013-05-31T16:39:41.674148 #2] INFO -- : Started GET "/" for 67.244.94.162 at 2013-05-31 16:39:41 +0000 2013-05-31T16:39:41.676969+00:00 heroku[router]: at=info method=GET path=/ host=floating-refuge-5703.herokuapp.com fwd="67.244.94.162" dyno=web.1 connect=0ms service=5ms status=404 bytes=1351 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/application.rb:96:in `call' 2013-05-31T16:39:41.676961+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-05-31T16:39:41.677196+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' 2013-05-31T16:39:41.677665+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:67:in `tagged' 2013-05-31T16:39:41.677665+00:00 app[web.1]: 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-4.0.0.rc1/lib/action_dispatch/middleware/static.rb:64:in `call' 2013-05-31T16:39:41.677665+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/cache/strategy/local_cache.rb:83:in `call' 2013-05-31T16:39:41.677665+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' 2013-05-31T16:39:41.677665+00:00 app[web.1]: 2013-05-31T16:39:41.677196+00:00 app[web.1]: F,[2013-05-31T16:39:41.675079 #2] FATAL -- : 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/tagged_logging.rb:25:in `tagged' 2013-05-31T16:39:41.677432+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-4.0.0.rc1/lib/rails/application.rb:96:in `call' 2013-05-31T16:39:41.677665+00:00 app[web.1]: vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
解决方法
其次,我建议你忽略你所链接的question中给出的建议,因为它与rails4没有任何关系.如果您使用heroku,则不需要对您的资产进行编译.当您将应用程序推送到他们时,它们会为您做.这可能值得删除您在运行的rake资产时创建的公共/资产文件夹:预编译,因为它会妨碍
第三,删除您添加到config / application.rb的代码,因为有no assets group in Rails 4
第四,heroku用来注入一个插件来为您的应用程序提供静态资源,但是现在您需要通过将以下内容添加到您的Gemfile中来添加到do that yourself:
gem 'rails_log_stdout',github: 'heroku/rails_log_stdout' gem 'rails3_serve_static_assets',github: 'heroku/rails3_serve_static_assets'
X-4545 X- 200 X- 200 200 X- 200 X- 200 200 X- 200 200: 200新X- 200 200 X- 200 200 X- 200 200 X- 200 200 X- 200 X- 20045 X-
最后,不要担心默认的Rails着陆页不会显示在Heroku上.这可能是他们的系统中的错误,它发生在我身上,这将会发生在下一个人身上,如果他也尝试了,这可能会发生在Matz.这没什么大不了的.新新旗新新新旗新新新旗新新旗旗新新旗旗新新旗新旗旗您的应用程序已准备好开始开发自己的着陆页.
祝你好运,为什么值得,这是一个非常简单的例子Gemfile优化为英雄:
source 'https://rubygems.org' # you are using Ruby 1.9.3,better to 2.0.0 upgrade for more speed 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.0.1' # The asset_sync gem is WELL worth using # but you should read more about it before deciding # https://github.com/rumblelabs/asset_sync # gem 'asset_sync' # only want sqlite in dev and test envs group :development,:test do gem 'sqlite3' end group :production do gem 'pg' # dont want sqlite in production gem 'unicorn' # make sure you follow installation instructions for this gem gem 'rails_log_stdout',github: 'heroku/rails_log_stdout' gem 'rails3_serve_static_assets',github: 'heroku/rails3_serve_static_assets' end group :doc do gem 'sdoc',require: false end