Skip to content

Commit

Permalink
when whitelist attributes is turned on we need to explicitly assign t…
Browse files Browse the repository at this point in the history
…he params
  • Loading branch information
mjankowski committed Apr 6, 2012
1 parent 3e74aac commit 8bea080
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/controllers/clearance/users_controller.rb
Expand Up @@ -5,12 +5,12 @@ class Clearance::UsersController < ApplicationController
before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in? before_filter :redirect_to_root, :only => [:new, :create], :if => :signed_in?


def new def new
@user = Clearance.configuration.user_model.new(params[:user]) @user = user_from_params
render :template => 'users/new' render :template => 'users/new'
end end


def create def create
@user = Clearance.configuration.user_model.new(params[:user]) @user = user_from_params
if @user.save if @user.save
sign_in(@user) sign_in(@user)
redirect_back_or(url_after_create) redirect_back_or(url_after_create)
Expand All @@ -31,4 +31,13 @@ def flash_failure_after_create
def url_after_create def url_after_create
'/' '/'
end 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 end

0 comments on commit 8bea080

Please sign in to comment.