0

我的设计设置以前运行良好,但现在,出于某种原因,每当我尝试注册新用户时,它都会尝试调用 users#create 而不是 registrations#create。我认为这一定是我的 routes.rb 文件有问题。我最近向我的应用程序添加了一个新资源“首选项”,因此路由可能很不稳定:

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
4

1 回答 1

2

UsersController应该有create方法。如果您不想编写自己的注册逻辑,只需从Devise::RegistrationsController < DeviseController继承:

 controller UsersController < Devise::RegistrationsController
      #....
 end

这将包括默认的设计方法。

于 2012-07-10T13:51:09.480 回答