我想在我的网站中添加 OpenID 身份验证。为此,我遵循了几个教程并使用了几个插件和 gem,最后我设法使用devise_openid_authenticatable gem做一些事情。我也有正常的登录/密码验证、Facebook 验证和 Twitter 验证。这三个工作完美。
现在我试图覆盖 Devise's Session Controller
,但是当我这样做时,正常的登录名/密码停止工作。我得到的错误是:
ActiveRecord::RecordNotFound in Sessions#create
Couldn't find User without an ID
其余的身份验证表格都可以正常工作,即使注册也很完美。这只是登录/密码身份验证方法...
我使用 Rails 3.0.1、Ruby 1.8.9 和 Devise 1.4.9
路线.rb
MAWeb::Application.routes.draw do
[...]
devise_for :admins
devise_for :users, :controllers => {:registrations => 'registrations', :sessions => 'sessions'}
match '/users/openid' => 'users#openid_sign_in'
match 'openid/sign_in' => 'openid#sign_in', :as => :openid_sign_in
get 'openid/create'
match '/auth/:provider/callback' => 'authentications#create'
match '/auth/failure' => 'authentications#failure'
resources :subscription_contact_datas
resources :subscription_preferences do
collection do
post :create_with_params
end
member do
get 'delete_tag'
end
get 'fill_event_id', :on => :member
end
resources :event_states
resources :subscription_profiles do
collection do
put :update_profiles
end
end
resources :event_criteria_options
resources :subscriptions do
collection do
get :options_for_event_criteria
end
end
resources :event_criterias
resources :categories
resources :user_infos do
member do
get 'edit'
end
end
resources :events
resources :users do
member do
get 'showUserActivity'
end
end
resources :admins
resources :subscriptions_from_poi
root :to => "home#index"
namespace :user do
root :to => "users#index"
end
namespace :admin do
root :to => "admins#index"
end
*注册控制器的覆盖工作完美
编辑:添加了大部分路线。在我看来,我忽略的那些并不重要。