Ursus
Ursus

Reputation: 30056

My model doesn't save others field in addition to those of Devise

I'm developing a web application with Rails and I'm using Devise gem. I added a field in Devise registration view but when I sign up a user, in the database only that field is empty. Am I missing something? Thank you in advance.

Upvotes: 0

Views: 80

Answers (1)

vs4vijay
vs4vijay

Reputation: 1205

This is because Devise strong parameter sanitizer. Just add following lines to your application_controller.rb.

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :first_name
  end

and call this configure_permitted_parameters method before filter for devise controller using before_filter.

   before_filter :configure_permitted_parameters, if: :devise_controller?

Ref: https://github.com/plataformatec/devise#strong-parameters

Upvotes: 1

Related Questions