我添加了omniauth并设计了宝石,并添加了facebook登录支持。这是我的routes.rb文件:
resources :authentications do
match 'auth/:provider/callback' => 'authentications/#create', :via => :post
end
我尝试发布以及进入via部分。 这是认证控制器的控制器。
def create
auth = request.env["rack.auth"]
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
这是rake路线输出
rake routes
authentications GET /authentications(.:format) authentications#index
POST /authentications(.:format) authentications#create
new_authentication GET /authentications/new(.:format) authentications#new
edit_authentication GET /authentications/:id/edit(.:format) authentications#edit
authentication GET /authentications/:id(.:format) authentications#show
PUT /authentications/:id(.:format) authentications#update
DELETE /authentications/:id(.:format) authentications#destroy
conferences GET /conferences(.:format) conferences#index
POST /conferences(.:format) conferences#create
new_conference GET /conferences/new(.:format) conferences#new
edit_conference GET /conferences/:id/edit(.:format) conferences#edit
conference GET /conferences/:id(.:format) conferences#show
PUT /conferences/:id(.:format) conferences#update
DELETE /conferences/:id(.:format) conferences#destroy
profiles GET /profiles(.:format) profiles#index
POST /profiles(.:format) profiles#create
new_profile GET /profiles/new(.:format) profiles#new
edit_profile GET /profiles/:id/edit(.:format) profiles#edit
profile GET /profiles/:id(.:format) profiles#show
PUT /profiles/:id(.:format) profiles#update
DELETE /profiles/:id(.:format) profiles#destroy
GET /conferences(.:format) conferences#index
POST /conferences(.:format) conferences#create
GET /conferences/new(.:format) conferences#new
GET /conferences/:id/edit(.:format) conferences#edit
GET /conferences/:id(.:format) conferences#show
PUT /conferences/:id(.:format) conferences#update
DELETE /conferences/:id(.:format) conferences#destroy
activity_bigbluebutton_server GET /bigbluebutton/servers/:id/activity(.:format) bigbluebutton/servers#activity
rooms_bigbluebutton_server GET /bigbluebutton/servers/:id/rooms(.:format) bigbluebutton/servers#rooms
bigbluebutton_servers GET /bigbluebutton/servers(.:format) bigbluebutton/servers#index
POST /bigbluebutton/servers(.:format) bigbluebutton/servers#create
new_bigbluebutton_server GET /bigbluebutton/servers/new(.:format) bigbluebutton/servers#new
edit_bigbluebutton_server GET /bigbluebutton/servers/:id/edit(.:format) bigbluebutton/servers#edit
bigbluebutton_server GET /bigbluebutton/servers/:id(.:format) bigbluebutton/servers#show
PUT /bigbluebutton/servers/:id(.:format) bigbluebutton/servers#update
DELETE /bigbluebutton/servers/:id(.:format) bigbluebutton/servers#destroy
external_bigbluebutton_rooms GET /bigbluebutton/rooms/external(.:format) bigbluebutton/rooms#external
POST /bigbluebutton/rooms/external(.:format) bigbluebutton/rooms#external_auth
join_bigbluebutton_room GET /bigbluebutton/rooms/:id/join(.:format) bigbluebutton/rooms#join
running_bigbluebutton_room GET /bigbluebutton/rooms/:id/running(.:format) bigbluebutton/rooms#running
end_bigbluebutton_room GET /bigbluebutton/rooms/:id/end(.:format) bigbluebutton/rooms#end
invite_bigbluebutton_room GET /bigbluebutton/rooms/:id/invite(.:format) bigbluebutton/rooms#invite
join_mobile_bigbluebutton_room GET /bigbluebutton/rooms/:id/join_mobile(.:format) bigbluebutton/rooms#join_mobile
POST /bigbluebutton/rooms/:id/join(.:format) bigbluebutton/rooms#auth
bigbluebutton_rooms GET /bigbluebutton/rooms(.:format) bigbluebutton/rooms#index
POST /bigbluebutton/rooms(.:format) bigbluebutton/rooms#create
new_bigbluebutton_room GET /bigbluebutton/rooms/new(.:format) bigbluebutton/rooms#new
edit_bigbluebutton_room GET /bigbluebutton/rooms/:id/edit(.:format) bigbluebutton/rooms#edit
bigbluebutton_room GET /bigbluebutton/rooms/:id(.:format) bigbluebutton/rooms#show
PUT /bigbluebutton/rooms/:id(.:format) bigbluebutton/rooms#update
DELETE /bigbluebutton/rooms/:id(.:format) bigbluebutton/rooms#destroy
/auth/:provider/callback(.:format) authentications/#create
root / profiles#new
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
答案 0 :(得分:1)
这个
match 'auth/:provider/callback' => 'authentications/#create', :via => :post
应该是
match 'auth/:provider/callback' => 'authentications#create', :via => :post
authentications
是控制者& create
是方法