私のルートファイル:
namespace :api, defaults: {format: 'json'} do
scope module: :v1, constraints: ApiConstraints.new(version: 1, default:true) do
resources :product_types, only: [:index, :show]
resources :products, only: [:index, :show]
resources :companies, only: [:index, :show]
resources :categories, only: [:index, :show]
resources :machines, only: [:index, :show]
resources :shops, only: [:index, :show]
resources :tokens, only: [:create, :destroy]
resources :receipts, only: [:create, :show] do
collection { post :create_full }
end
end
end
生成されたルート:
create_full_api_receipts POST /api/receipts/create_full(.:format) api/v1/receipts#create_full {:format=>"json"}
api_receipts POST /api/receipts(.:format) api/v1/receipts#create {:format=>"json"}
api_receipt GET /api/receipts/:id(.:format) api/v1/receipts#show {:format=>"json"}
アクション create_full は内に存在しreceipts_controller
ます/app/controllers/api/v1/receipts_controller.rb
これは結果のログです:
Started POST "/api/receipts/create_full?auth_token=cu1WDF9zZketmT2QC6Bg" for 127.0.0.1 at 2013-05-30 19:43:25 +0100
AbstractController::ActionNotFound (The action 'create_full' could not be found for ReceiptsController):
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/base.rb:116:in `process'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/rendering.rb:45:in `process'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal.rb:203:in `dispatch'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal.rb:246:in `block in action'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/routing/route_set.rb:73:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/routing/route_set.rb:36:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/routing/mapper.rb:42:in `call'
rails/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
rails/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
rails/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/routing/route_set.rb:601:in `call'
rails/ruby/1.9.1/gems/apipie-rails-0.0.21/lib/apipie/static_dispatcher.rb:56:in `call'
rails/ruby/1.9.1/gems/versionist-1.0.0/lib/versionist/middleware.rb:39:in `_call'
rails/ruby/1.9.1/gems/versionist-1.0.0/lib/versionist/middleware.rb:17:in `call'
rails/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
rails/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
rails/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/head.rb:14:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/flash.rb:242:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/cookies.rb:341:in `call'
rails/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/query_cache.rb:64:in `call'
rails/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
rails/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `_run__193663097__call__616363874__callbacks'
rails/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
rails/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
rails/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:65:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/rack/logger.rb:32:in `call_app'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/rack/logger.rb:16:in `block in call'
rails/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/tagged_logging.rb:22:in `tagged'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/rack/logger.rb:16:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/request_id.rb:22:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
rails/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/static.rb:62:in `call'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:479:in `call'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:223:in `call'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/rack/log_tailer.rb:17:in `call'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `catch'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:54:in `process'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
rails/ruby/1.9.1/gems/eventmachine-1.0.3-x86-mingw32/lib/eventmachine.rb:187:in `run_machine'
rails/ruby/1.9.1/gems/eventmachine-1.0.3-x86-mingw32/lib/eventmachine.rb:187:in `run'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
rails/ruby/1.9.1/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
rails/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:268:in `start'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
rails/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
Rendered rails/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb within rescues/layout (99.0ms)
なぜこれが起こるのか私にはわかりません..そうですか?