I have added a t.boolean :admin
field to my Devise migration file. It was saying that it was an unpermitted parameter in the console so I attempted to create a protected permitter for the :admin
value when the form is submitted.
Here is my Users::RegistrationsController < Devise::RegistrationsController
:
class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_permitted_parameters
protected
#Permitting the admin boolean
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up).push(:admin)
end
end
And my routes.rb
file with the devise_for
method.
devise_for :users, :controllers => { :registrations => "users/registrations" }
I cannot seem to fix ActionController::RoutingError (uninitialized constant Users):
despite me looking on stack overflow for 30 minutes and trying to rename a couple of things. Any ideas?
Your controller has probably the wrong name or it is placed in the wrong folder. When following Ruby on Rails conventions then a controller named Users::RegistrationsController
should be defined in a file named app/controllers/users/registrations_controller.rb
.