app/controllers/users_controller.rb
# destroys/deletes a specified user account
# updates skate_spots user_id to admin id since admin should never be deleted
destroys/deletes a specified user account
updates skate_spots user_id to admin id since admin should never be deleted
destroys / deletes a specified user account updates skate_spots user_id to admin id since admin should never be deleted
def destroy
    @user = User.find(params[:id]) 
		@admin = User.where(:admin => true).first
		rateArray = Array.new
		if @user.skate_spots.any?
			@user.skate_spots.update_all("user_id = #{@admin.id}")
		end
	  Event.where(:user_id => @user.id).update_all("user_id = #{@admin.id}")
	  Rating.where(:user_id => @user.id).destroy_all
    @user.destroy 
    flash[:success] = "User deleted"
    redirect_to users_url
  end
def destroy @user = User . find ( params [ :id ] ) @admin = User . where ( :admin => true ) . first rateArray = Array . new if @user . skate_spots . any? @user . skate_spots . update_all ( "user_id = #{@admin.id}" ) end Event . where ( :user_id => @user . id ) . update_all ( "user_id = #{@admin.id}" ) Rating . where ( :user_id => @user . id ) . destroy_all @user . destroy flash [ :success ] = "User deleted" redirect_to users_url end
destroys/deletes a specified user account
updates skate_spots user_id to admin id since admin should never be deleted
destroys / deletes a specified user account updates skate_spots user_id to admin id since admin should never be deleted
# rateArray << Rating.where(:user_id => @user.id).ids # User.find(params[:id]).destroy #method chaining combines find & destroy