I am trying to add name, surname and birthdate to devise registration with Spree.
I have installed the gem
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
Created the migration:
class AddFieldsToSpreeUsers < ActiveRecord::Migration
def change
add_column :spree_users, :name, :string
add_column :spree_users, :surname, :string
add_column :spree_users, :birthdate, :time
end
end
Created a new form to add the fields app/views/spree/shared/_user_form.html.erb
Defined a method in application controller to run with a before action
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :set_locale
before_filter :configure_permitted_parameters, if: :devise_controller?
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :name, :surname, :birthdate) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :name, :surname, :birthdate) }
end
end
And I am still getting no records in the database
<Spree::User id: 2, encrypted_password: "bdd86072513f789da5a395080e3d16e28c96cfe5e3aaea105b...",
... , name: nil, surname: nil, birthdate: nil>
Here is the console log for the add user form submit action:
Started POST "/signup" for ::1 at 2015-07-21 09:52:08 -0500
Processing by Spree::UserRegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+9EoKHj9fkHqKF8TRtlcfIYt5+QPuPa1ynmWVifUNY3luiCDpiBP9z2VV/uMAH1JP0CCg7gwG2gu7vO1TaSacw==", "spree_user"=>{"name"=>"Christophe", "surname"=>"Mysurname", "email"=>"email@gmail.com", "password"=>"[FILTERED]", "birthdate"=>"1978-11-11"}, "commit"=>"Create"}
Unpermitted parameters: name, surname, birthdate
(0.6ms) BEGIN
What am i doing wrong? I have unpermitted parameters.