0

我想在我的应用程序中添加使用 JSON 格式和其他一些特定内容注册的选项。我尝试添加自己的RegistrationsController控制器,然后将路线设置为如下所示:

devise_for :users, :path_names => { :sign_in => 'signin', :sign_out => 'signout', :sign_up => 'signup' }
match 'signin', :to => 'devise/sessions#new', :as => "new_user_session"
match 'signout', :to  => 'devise/sessions#destroy', :as => "destroy_user_session"
match 'signup(.:format)', :to => 'registrations#new', :as => "new_user_registration"

RegistrationsController在 app/controllers/registrations_controller.rb 中看起来像这样:

class RegistrationsController < Devise::RegistrationsController
  prepend_view_path "app/views/devise"
  def create
    # My custom implementation
  end
end

无论格式如何,它总是抛出以下错误

AbstractController::ActionNotFound (AbstractController::ActionNotFound):
/usr/local/Cellar/Gems/1.8/gems/devise-1.1.rc2/lib/devise/controllers/internal_helpers.rb:57:in `is_devise_resource?'
...

我什至尝试将注册控制器从 git 添加到 app/controllers/devise/registrations_controller.rb 并更改路由以指向那个,但这也不起作用。有人有想法吗?

4

1 回答 1

1

弄清楚了!我试图覆盖注册控制器中的创建,但没有路由到它......愚蠢的错误。

devise_for :users, :path_names => { :sign_in => 'signin', :sign_out => 'signout', :sign_up => 'signup' }, :controllers => { :registrations => "registrations" }
match 'signin', :to => 'devise/sessions#new', :as => "new_user_session"
match 'signout', :to  => 'devise/sessions#destroy', :as => "destroy_user_session"
get 'signup', :to => 'registrations#new', :as => "new_user_registration"
post 'signup(.:format)', :to => 'registrations#create', :as => "create_user_registration"
于 2010-07-14T16:29:11.427 回答