Closed s0rin closed 7 years ago
Thanks mine is working
Thanks mine working now.
Thanks Alot for this solution
@s0rin Hi, can you help me? i added permit params but it doesn't works, i got error Unpermitted parameter: name registrations_controller.rb:
module Users
class RegistrationsController < Devise::RegistrationsController
before_action :configure_permitted_parameters
prepend_before_action :check_captcha, only: %i[create]
def create; end
protected
def check_captcha
unless verify_recaptcha
self.resource = resource_class.new sign_up_params
resource.validate
respond_with_navigational(resource) { render :new }
end
end
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: %i[name])
devise_parameter_sanitizer.permit(:account_update, keys: %i[name])
end
end
end
routes:
devise_for :users, controllers: { registrations: 'users/registrations',
omniauth_callbacks: 'users/omniauth_callbacks' }
console logs;
Started POST "/users?locale=uk" for 127.0.0.1 at 2018-02-03 20:49:21 +0200
Processing by Users::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"zvj1RuW1RE3heA+nVyDEiHoFSG9xhVinuGFpPfeWkIYumwnfJY9wGjqMgbwwNR9fGmzB5skVTumBizeXwL6W4A==", "user"=>{"name"=>"aaaaaaaaaaaaaaa", "email"=>"bogdanlitvin8@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "g-recaptcha-response"=>"03AA7ASh1w9oPRas4LD8JRB2rduV2FjBiOUvsOeWydKiLRh8NWC7rxS_-PPlyFCx2Q3p6_cM963XlMsKTp7xFeqNC9uxSleFK1GNUMeTXkGh7b1BRSzZnZegbKH39mIYLBtqI11g7o7RJ8pz4q1dHtHc5CnwMdUVKsGFy5shgrCduaaqqsHEJhWdD6y6DRRAmt1RmU0CRwt3S_zEOYdiRTSm7YWB-GM7aEJrZF0MUrNjywmoJ96su77DLXUtitpnrFlKgU835aH9jU9oY0QkPjVN7gm5tcS3-D1Xo2W9Mlgatr1Ly1zskPUXKudV84kUDiFce95TTdHHfcQroYM4SwFn-YOvRXVSAZqUcfxAnoGht-cE4pzxuVk18lOdXoMcEzZB9eIC44SqIeCKPABdM5b9galALSOclfbLD5yOkbV6pKfjUyy1Ihfg5IgtJYv3KX3-In8unTkjpLpA4axwJHloQq5Oe1r83wLA", "commit"=>"registration", "locale"=>"en"}
Unpermitted parameter: name
User Exists (0.8ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "bogdanlitvin8@gmail.com"], ["LIMIT", 1]]
Rendering devise/registrations/new.html.slim within layouts/application
Rendered devise/shared/_links.html.slim (3.5ms)
Rendered devise/registrations/new.html.slim within layouts/application (12.2ms)
Rendered layouts/_alert.html.slim (2.3ms)
Rendered layouts/_header.html.slim (11.5ms)
Filter chain halted as :check_captcha rendered or redirected
Completed 200 OK in 345ms (Views: 110.4ms | ActiveRecord: 10.6ms | Solr: 0.0ms)
Also worked for me, Thanks a lot!
Thank you, now it's working again
The .for method is deprecated in 4.1 +
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :name
devise_parameter_sanitizer.for(:account_update) << :name
end
This should work
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end