Skip to content
Browse files

when whitelist attributes is turned on we need to explicitly assign t…

…he params
  • Loading branch information...
1 parent 3e74aac commit 8bea080cf5df69a46c569cd6b4c14c7bbf3210f7 @mjankowski mjankowski committed Apr 4, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 app/controllers/clearance/users_controller.rb
View
13 app/controllers/clearance/users_controller.rb
@@ -5,12 +5,12 @@ class Clearance::UsersController < ApplicationController
before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?
def new
- @user = Clearance.configuration.user_model.new(params[:user])
+ @user = user_from_params
render :template => 'users/new'
end
def create
- @user = Clearance.configuration.user_model.new(params[:user])
+ @user = user_from_params
if @user.save
sign_in(@user)
redirect_back_or(url_after_create)
@@ -31,4 +31,13 @@ def flash_failure_after_create
def url_after_create
'/'
end
+
+ def user_from_params
+ user_params = params[:user] || Hash.new
+ email, password = user_params.delete(:email), user_params.delete(:password)
+ Clearance.configuration.user_model.new(user_params).tap do |user|
+ user.email = email
+ user.password = password
+ end
+ end
end

0 comments on commit 8bea080

Please sign in to comment.
Something went wrong with that request. Please try again.