All threads / Rails 4.0 and Devise With Strong Params and Custom Fields Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Rails 4.0 and Devise With Strong Params and Custom Fields Discussion

Chris Oliver asked in General

Short and simple. Thanks a lot. I've been looking for a solution all morning.

This works for me except i use simple_form_for
Thanks.

Rodrigo Sanguanini ·

You can use instead of

devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :full_name, :phone) }

This

devise_parameter_sanitizer.for(:sign_up) << :full_name, :phone

Thanks Rodrigo! Definitely a cleaner implementation because this way you're only adding fields.

How do permit strong parameters if I have multiple devise models?

That's a good question. I've never actually checked into that. You should ask on the Github Issues for Devise. They'll definitely know the answer to that.

Fixed it. I just inherited Devise::ParameterSanitizer to Admin::ParameterSanitizer and User::ParameterSanitizer and wrote my logic for all pages, sign_in sign_up etc. as separate mthods. Works just fine.

Junk Kerberos ·

How to Keep form fields filled after an error in signup?

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.