Why doesn’t this work? I’m using byebug to debug. All the parameters are there as intended.
Started POST "/users" for 127.0.0.1 at 2016-03-22 16:12:56 -0400
Processing by Users::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"NjRZalKR067T+dchCQYJKdCCpXcCu5ljPMGA/r6t4pMZh2ZmyPL8cEUvX8usjBigqUI4w5Xfxjux+HxmQp029g==", "user"=>{"first"=>"wadson", "last"=>"wadson", "password"=>"[FILTERED]"}, "commit"=>"Sign up"}
(0.1ms) begin transaction
(0.2ms) rollback transaction
Rendered devise/shared/_links.html.erb (5.4ms)
Rendered devise/registrations/new.html.haml within layouts/application (20.5ms)
Completed 200 OK in 300ms (Views: 181.7ms | ActiveRecord: 0.4ms)
(byebug) params
{"utf8"=>"✓", "authenticity_token"=>"iV8+dZtxz0NFRE19fmkaH2KfEABJt6yUYoK9WLE47Sqm7AF5ARLgndOSxZfb4wuWG1+NtN7T88zvu0HATQg5Tw==", "user"=>{"password"=>"8005551212", "email"=>"homers@website.com"}, "commit"=>"Sign up", "controller"=>"users/registrations", "action"=>"create"}
(byebug)
registrations_controller.rb
def account_email(first, last)
"#{first.downcase}#{last.downcase.first}@website.com"
end
# POST /resource
def create
params[:user][:email]=account_email(params[:user][:first],params[:user][:last])
super
params[:user].delete(:first)
params[:user].delete(:last)
end
Below is my signup form…
new.html.haml
.container
%h2 Sign up
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true, class: "form-control input-sm"
= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length)
= f.input :password_confirmation, required: true
.form-actions
= f.button :submit, "Sign up"
= render "devise/shared/links"