verifying user exists before trying to update

This commit is contained in:
Mike McCabe
2013-10-09 11:08:39 -04:00
parent a93159c9f2
commit bbed455178
+5
View File
@@ -33,6 +33,7 @@ class UsersController < ApplicationController
#user = User.find(:first, :conditions => ["user_id = ?", "#{params[:user][:user_id]}"])
user = User.find(:first, :conditions => "user_id = '#{params[:user][:user_id]}'")
if user
user.skip_user_id_assign = true
user.skip_hash_password = true
user.update_attributes(params[:user].reject { |k| %w(password password_confirmation user_id).include? k })
@@ -45,6 +46,10 @@ class UsersController < ApplicationController
format.html { redirect_to user_account_settings_path(:user_id => current_user.user_id) }
format.json { render :json => {:msg => message ? "success" : "false "} }
end
else
flash[:error] = "Could not update user!"
redirect_to user_account_settings_path(:user_id => current_user.user_id)
end
end
end