app/controllers/my_maps_controller.rb
def destroy
  if (@user == current_user and !current_user.own_this_map?(params[:map_id]))

    my_map = @user.my_maps.find_by_map_id(params[:map_id])

    if my_map.destroy 
      flash[:notice] = "Map removed from list!"
    else
      flash[:notice] = "Map coudn't be removed from list"
    end
  else
    if current_user.own_this_map?(params[:map_id])
       flash[:notice]= "Sorry, you cannot remove maps you have uploaded, from the list"
    else
       flash[:notice]= "Map coudn't be removed from list"
    end

   

  end
redirect_to my_maps_path
end
#we shouldnt be able to remove a map we uploaded
we shouldnt be able to remove a map we uploaded
we shouldnt be able to remove a map we uploaded
def destroy
  if (@user == current_user and !current_user.own_this_map?(params[:map_id]))
    my_map = @user.my_maps.find_by_map_id(params[:map_id])
    if my_map.destroy 
      flash[:notice] = "Map removed from list!"
    else
      flash[:notice] = "Map coudn't be removed from list"
    end
  else
    if current_user.own_this_map?(params[:map_id])
       flash[:notice]= "Sorry, you cannot remove maps you have uploaded, from the list"
    else
       flash[:notice]= "Map coudn't be removed from list"
    end
  end
redirect_to my_maps_path
end
def destroy if ( @user == current_user and ! current_user . own_this_map? ( params [ :map_id ] ) ) my_map = @user . my_maps . find_by_map_id ( params [ :map_id ] ) if my_map . destroy flash [ :notice ] = "Map removed from list!" else flash [ :notice ] = "Map coudn't be removed from list" end else if current_user . own_this_map? ( params [ :map_id ] ) flash [ :notice ] = "Sorry, you cannot remove maps you have uploaded, from the list" else flash [ :notice ] = "Map coudn't be removed from list" end end redirect_to my_maps_path end
we shouldnt be able to remove a map we uploaded
we shouldnt be able to remove a map we uploaded