Permalink
Browse files

Fixed pretty_url error on user creation

  • Loading branch information...
nebirhos committed May 28, 2012
1 parent 26f4d62 commit 125b0c900b2835afd266133acfc4bf81c4a4323f
Showing with 10 additions and 2 deletions.
  1. +10 −2 app/controllers/admin/users_controller.rb
@@ -26,7 +26,11 @@ def create
@admin_editing_language = admin_editing_language
@user = User.new(params[:user])
@user.set_roles(params[:user][:role_ids])
- @user.pretty_url = @user.pretty_url.urlify.blank? ? "#{@user.firstname}-#{@user.lastname}".urlify : @user.pretty_url.urlify
+ if @user.pretty_url and @user.pretty_url.urlify.present?
+ @user.pretty_url = @user.pretty_url.urlify
+ else
+ @user.pretty_url = "#{@user.firstname}-#{@user.lastname}".urlify
+ end
if @user && @user.save && @user.errors.empty?
params[:user][:enabled] == '1' ? @user.enable! : @user.disable!
redirect_to admin_users_path
@@ -50,7 +54,11 @@ def update
end
@user.set_roles(params[:user][:role_ids])
@user.attributes = params[:user] unless @user.blank?
- @user.pretty_url = @user.pretty_url.urlify.blank? ? "#{@user.firstname}-#{@user.lastname}".urlify : @user.pretty_url.urlify
+ if @user.pretty_url and @user.pretty_url.urlify.present?
+ @user.pretty_url = @user.pretty_url.urlify
+ else
+ @user.pretty_url = "#{@user.firstname}-#{@user.lastname}".urlify
+ end
if @user && @user.save && @user.errors.empty?
params[:user][:enabled] == '1' ? @user.enable! : @user.disable!
params[:save_and_close] ? (redirect_to admin_users_path()) : (render :action => "edit")

0 comments on commit 125b0c9

Please sign in to comment.