我的设计设置之前工作正常,但现在,出于某种原因,每当我尝试注册一个新用户时,它都会尝试调用用户#create而不是注册#create。我认为我的routes.rb文件一定是个问题。我最近在我的应用程序中添加了一个新资源“preferences”,因此路由可能会很糟糕:
Indexer2::Application.routes.draw do
resources :preferences
get "home/index"
resources :posts
resources :users
devise_for :users, :controllers => {:registrations => 'registrations', :invitations => 'invitations'}, :except => [:show] do
get "/signup" => "devise/registrations#new", :as => 'user_signup'
get '/logout' => 'devise/sessions#destroy', :as => 'user_logout'
get '/login' => "devise/sessions#new", :as => 'user_login'
end
match '/welcome' => 'pages#welcome'
resources :preferences, :except => [:destory, :edit, :create, :new, :index, :show] do
collection do
post "make_feed_preference"
post "change_preference"
end
end
root :to => "home#index"
end
答案 0 :(得分:2)
您的UsersController
应该有create
方法。
如果您不想编写自己的注册逻辑,只需从Devise::RegistrationsController < DeviseController继承:
controller UsersController < Devise::RegistrationsController
#....
end
这将包括默认的Devise方法。