2013-03-17 121 views
1

我已经在我的routes.rb以下Heroku的路由错误:ActionController的:: RoutingError

constraints subdomain: 'api' do 
    namespace :api, path: nil, defaults: {format: 'json'} do 
     namespace :v1 do 
     resources :cities, only: [:index] do 
      resources :areas, only: [:index] 
     end 
     end 
    end 
    end 

在本地测试,它的工作原理,但是当我部署到Heroku的我得到以下错误:

2013-03-17T20:35:04+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/v1/cities.json"): 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/logger.rb:32:in `call_app' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `block in call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:in `tagged' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/static.rb:62:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/engine.rb:479:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:223:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.8.72/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:18:in `call' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:552:in `process_client' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:632:in `worker_loop' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.8.72/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:18:in `block (4 levels) in <top (required)>' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:142:in `start' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in `spawn_missing_workers' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn_rails:209:in `<top (required)>' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/bin/unicorn_rails:23:in `load' 
2013-03-17T20:35:04+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/bin/unicorn_rails:23:in `<main>' 

回答

0

将您的Heroku上的主人设置为api.yourdomain或者您使用subdomain.herokuapp.com host:

如果子域不api,那么这条线会导致您的路线失败:

constraints subdomain: 'api' do 
+0

api.mydomain.com,子域是设置为指向的Heroku。 – ismail 2013-03-17 22:00:05

+0

你的域名tld和heroku是一样的吗?我的.com.br和我得到了同样的错误,为了解决我不得不将config.action_dispatch.tld_length = 2添加到production.rb文件的问题。 – 2013-08-05 19:10:06

相关问题