devise overriding registrations controller - uninitialized constant Users::RegistrationsController

后端 未结 6 1849
时光说笑
时光说笑 2021-01-04 04:34

I\'m trying to override some the functionality of the default devise registrations controller so that only certain users can create accounts for others. So in a file called

相关标签:
6条回答
  • 2021-01-04 05:02

    Do rails routes and check your routes in config/routes you might have a typo in your routes.

    Instead of registrationS#new you might have something else like registration#new.

    0 讨论(0)
  • 2021-01-04 05:03

    Hi I just recently added first name and last name to my registration. I am using Rails 4.

    I used the following instructions/tutorial to get this done:

    http://www.jacopretorius.net/2014/03/adding-custom-fields-to-your-devise-user-model-in-rails-4.html.

    :)

    0 讨论(0)
  • 2021-01-04 05:09

    I would say, there's something wrong at your filename.

    Your file should be called users/registrations_controller.rb

    That works for me.

    0 讨论(0)
  • 2021-01-04 05:10

    Where was your registrations_controller.rb saved to? The location is important. I found that I was making a mistake saving it to app/controllers/devise/.. It simply needed to be saved in app/controllers/. e.g.:

    app/controllers/registrations_controller.rb


    Also, config/routes.rb route should be defined as:

    devise_for :users, controllers: { registrations: 'registrations' }

    0 讨论(0)
  • 2021-01-04 05:13

    I tried the same setup that you put here but it worked for me. I uploaded the application to github (I uploaded the log as well, so you can see that it really worked).

    Double check for possible typos. Maybe you forgot a plural or there is a typo on a Class name.

    0 讨论(0)
  • 2021-01-04 05:20

    If you has been generate the views Move view files

    I assume you already use rails generate devise:views generated devise views. Move views/devise/registrations folder to views/users , I think you also you should change the _path in the forms

    0 讨论(0)
提交回复
热议问题