1

私のroutes.rbには次のものがあります

  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>'
4

1 に答える 1

0

Heroku のホストは に設定されていますかapi.yourdomain、またはホストを使用していsubdomain.herokuapp.comますか?

サブドメインが でない場合api、この行によりルートが失敗します。

constraints subdomain: 'api' do
于 2013-03-17T21:02:34.450 に答える