ruby on rails - Adding extra registration fields with Devise -


i trying add fields registrations#new. since want data , not need different functionality, don't see why need override controllers etc. did modify registrations#new follows:

enter image description here

to enable these fields through sanitizer, updated applicationcontroller follows:

enter image description here

for reason, not working , fields go database nulls.

i using ruby 2 , rails 4 rc1, devise 3.0.0.rc.

it appear code sample in question not working because not setting before_filter call sanitizer.

before_filter :configure_permitted_parameters, if: :devise_controller? 

with said, it's better override controller, shown in accepted answer, application controller isn't doing check of time. accepted answer can shortened code below. i've tested code application , works well. of documented in strong parameters section of readme in 3.0.0.rc tag.

override controller:

class registrationscontroller < devise::registrationscontroller   before_filter :configure_permitted_parameters, :only => [:create]    protected      def configure_permitted_parameters       devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password) }     end end 

then update routes use it:

devise_for :members, :controllers => { :registrations => "registrations" } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -