カスタム Facebook 認証パスを設定しようとしていますが、この役に立たないデバイス エラーが一貫して発生しています。ルート用に devise_scope を設定する必要があると書かれていますが、ご覧のとおり、そうしています! このエラーを機能させるために他に何をすべきかわかりません。
MyApp::Application.routes.draw do
root :to => 'high_voltage/pages#show', id: 'index'
namespace :api, defaults: {format: :json} do
namespace :v1 do
# i've removed all the extra routes for other resources.
# I do not have one for users set up
devise_for :users
devise_scope :user do
post '/users/facebook', to: 'sessions#facebook'
end
get 'users/:id/events', to: 'users#events'
end
end
end
私の投稿
myapp[development*] $ curl -H 'Content-Type: application/json' -d '{"auth_token": "12345"}' http://localhost:3000/api/v1/users/facebook
そしてエラー
AbstractController::ActionNotFound at /api/v1/users/facebook
============================================================
> Could not find devise mapping for path "/api/v1/users/facebook".
This may happen for two reasons:
1) You forgot to wrap your route inside the scope block. For example:
devise_scope :user do
get "/some/route" => "some_devise_controller"
end
2) You are testing a Devise controller bypassing the router.
If so, you can explicitly tell Devise which mapping to use:
@request.env["devise.mapping"] = Devise.mappings[:user]
devise (3.1.1) app/controllers/devise_controller.rb, line 84
------------------------------------------------------------
``` ruby
79 @navigational_formats ||= Devise.navigational_formats.select { |format| Mime::EXTENSION_LOOKUP[format.to_s] }
80 end
81
82 def unknown_action!(msg)
83 logger.debug "[Devise] #{msg}" if logger
> 84 raise AbstractController::ActionNotFound, msg
85 end
86
87 # Sets the resource creating an instance variable
88 def resource=(new_resource)
89 instance_variable_set(:"@#{resource_name}", new_resource)
```
App backtrace
-------------
Full backtrace
--------------
- devise (3.1.1) app/controllers/devise_controller.rb:84:in `unknown_action!'
- devise (3.1.1) app/controllers/devise_controller.rb:59:in `assert_is_devise_resource!'
- activesupport (4.0.0) lib/active_support/callbacks.rb:407:in `_run__4085891193320527193__process_action__callbacks'
- activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
- actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
- actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
- actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
- activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
- activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
- activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
- actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
- actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
- activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
- actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process'
- actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
- actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
- actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
- actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
- actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
- actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
- actionpack (4.0.0) lib/action_dispatch/routing/mapper.rb:44:in `call'
- actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
- actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
- actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
- meta_request (0.2.8) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
- rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
- meta_request (0.2.8) lib/meta_request/middlewares/headers.rb:16:in `call'
- meta_request (0.2.8) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
- rack-cors (0.2.8) lib/rack/cors.rb:54:in `call'
- warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
- warden (1.2.3) lib/warden/manager.rb:34:in `call'
- rack (1.5.2) lib/rack/etag.rb:23:in `call'
- rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
- rack (1.5.2) lib/rack/head.rb:11:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
- rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
- rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
- activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
- activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
- activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
- activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__753235512699108649__call__callbacks'
- activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
- actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
- better_errors (1.0.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
- better_errors (1.0.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
- better_errors (1.0.1) lib/better_errors/middleware.rb:56:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
- railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
- railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
- activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
- activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
- activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
- railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
- quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
- actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
- rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
- rack (1.5.2) lib/rack/runtime.rb:17:in `call'
- activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
- rack (1.5.2) lib/rack/lock.rb:17:in `call'
- actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
- railties (4.0.0) lib/rails/engine.rb:511:in `call'
- railties (4.0.0) lib/rails/application.rb:97:in `call'
- rack (1.5.2) lib/rack/content_length.rb:14:in `call'
- thin (1.6.1) lib/thin/connection.rb:82:in `block in pre_process'
- thin (1.6.1) lib/thin/connection.rb:80:in `pre_process'
- thin (1.6.1) lib/thin/connection.rb:55:in `process'
- thin (1.6.1) lib/thin/connection.rb:41:in `receive_data'
- eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
- thin (1.6.1) lib/thin/backends/base.rb:73:in `start'
- thin (1.6.1) lib/thin/server.rb:162:in `start'
- rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
- rack (1.5.2) lib/rack/server.rb:264:in `start'
- railties (4.0.0) lib/rails/commands/server.rb:84:in `start'
- railties (4.0.0) lib/rails/commands.rb:78:in `block in <top (required)>'
- railties (4.0.0) lib/rails/commands.rb:73:in `<top (required)>'
- bin/rails:4:in `<main>'
そしてコントローラー
class Api::V1::SessionsController < Devise::SessionsController
respond_to :json
before_filter :authenticate_user!, :except => [:create, :destroy]
skip_before_action :verify_authenticity_token
def facebook
end
end
そして最後に私のルート..
api_v1_users_facebook POST /api/v1/users/facebook(.:format) api/v1/sessions#facebook {:format=>:json}
エラーは、彼らが望むように正確にレイアウトしているため、まったく意味がありません.オンラインのソリューションからあらゆる種類のことを試しましたが、何も機能しません.
ありがとう!