Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
fixed bug where new user roles weren't being set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Nov 23, 2008
1 parent 65b8fb4 commit 5bfc106
Showing 1 changed file with 13 additions and 7 deletions.
Expand Up @@ -25,6 +25,7 @@ def new

def create
if @user.save
handle_roles
flash[:notice] = "User was created successfully."
redirect_to admin_users_path
else
Expand All @@ -41,13 +42,7 @@ def edit

def update
if @user.update_attributes(params[:user])
Role.base_roles.each do |role|
if params[:roles].include?(role)
@user.has_role(role)
else
@user.has_no_role(role)
end
end
handle_roles

flash[:notice] = "User was updated successfully."
redirect_to admin_users_path
Expand All @@ -62,4 +57,15 @@ def destroy
flash[:notice] = "User was deleted."
redirect_to admin_users_path
end

protected
def handle_roles
Role.base_roles.each do |role|
if params[:roles].include?(role)
@user.has_role(role)
else
@user.has_no_role(role)
end
end
end
end

0 comments on commit 5bfc106

Please sign in to comment.