-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Undefined method `concat'" on "devise_parameter_sanitizer.permit" #4477
Comments
This looks like a deprecation error. What Rails version are you using? |
Rails is on 4.2.1, Ruby is on version 2.3.1p112 and devise is also on 4.2.1. Sorry I took so long to reply! EDIT: Tried updating ruby to 2.4.0p0 and rails to 4.2.8, but the error persists. |
I think I see the problem. The action that should be passed must be the action your controller is trying to execute, which, in your case, is 'create'. From lib/devise/parameter_sanitize:84 : So I suggest you change the :sign_up symbol for :create, or the action name to 'sign_up' (since you are overwriting the RegistrationsController) and see where it goes. Remember that you can call 'super' if you need only to append some logic to the existing RegistrationsController#sign_up action. So, another alternative would be to change the action name to 'sign_up', check what Devise is already doing for you and complementing it with your own logic + a 'super' call for the ancestor method. I hope my comment helps :D also, sorry for the delayed response, pretty busy lately. |
Hello @marianatuma, thanks for your report. Thank you! |
I'm closing this issue because it has not had recent activity. Thank you! |
@marianatuma did you find a solution ? My initial state is to have an empty user table inside my database (no user registred)... i want to create one by sign_up. I added some columns in my database (username, family_name, second_name), then add them to this method "signup_params" inside app/controller/users/registrations_controller.rb file (i understand that it is the way to add these parameters to be valid with the other original ones from default devise one's). I think that 'concat' is call from somewhere for add (concat) these 3 entries to the default one to be "white-listed". These entry are ":username, :family_name, :second_name". I tryed with 'username', 'family_name', 'second_name' but same result. I searched for 'concat' code inside devise:
2 other files use this method for URL_HELPER and from authenticable.rb also... but i not understand the error message and what i'm supposed to do for fix this problem. I hope @marianatuma (if she find) to be able to share and help with this, or maybe someone other has an idea ? thank you for your help. |
@jerome-diver Can you please provide a sample application that reproduces the error? |
@jerome-diver I created a new application and included a Can you send us a sample application that reproduces that error? |
I'm closing this issue because it had no recent activity. Thank you! |
yes, i'm still facing the same problem. |
@jerome-diver Did you see the test app I sent you? I wasn't able to reproduce the issue, so I've asked for a sample application that does so I can see what's happening, but I didn't get any response, that's why I closed the issue. |
oh yes, sorry. Tell me if you have an idea where the problem can come from... |
@jerome-diver I took a look at your code and it turns out there are a couple of changes to be done in order for this to work: First, you're calling There are basically two ways to permit a list of keys using {:sign_in=>[:password, :remember_me], :sign_up=>[:password, :password_confirmation], :account_update=>[:password, :password_confirmation, :current_password]} Your application is first passing a block - in # app/controllers/application_controller.rb
devise_parameter_sanitizer.permit(:sign_up) { |p| p.permit(:username, :familly_name, :second_name, :email, :password, :password_confirmation) }
# @permitted[:sign_up] is now a Proc
<Proc:0x00007f9f9ff24630@/Users/tegon/src/public/aquaworks/app/controllers/application_controller.rb:15>
# app/controllers/users/registrations_controller.rb
devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :familly_name, :second_name])
@permitted[:sign_up].concat([:username, :familly_name, :second_name]) # error So basically what you have to do is remove one of the calls - I'd say to remove the I hope this helps. |
@tegon i just read your explication and this make sens, i understand (you explication is perfect also). Fantastic, i'm very happy because i was stick on that for long time now and really, you take time to explain clearly what"s happening. I correct my errors and now for sure, it is working perfectly. That was logic, i didn't know the way it works, i thinking it was over loading the method class (i was thinking wrong) and yes, it was one or the other and not together in application controller and user_registration controller... my bad. Thank you very much for your great and useful help @tegon. |
I'm using Rspec to test a custom RegistrationsController, and I haven't written a view yet, so I haven't tested this outside Rspec.
The full controller:
Am I doing something wrong?
Edit: just tested manually, error also happens.
The text was updated successfully, but these errors were encountered: