app/controllers/maps_controller.rb
#only allow deleting by a user if the user owns it
only allow deleting by a user if the user owns it
only allow deleting by a user if the user owns it
def check_if_map_can_be_deleted
    if logged_in? and (current_user.own_this_map?(params[:id])  or current_user.has_role?("editor"))
      @map = Map.find(params[:id])
    else
      flash[:notice] = "Sorry, you cannot delete other people's maps!"
      redirect_to map_path
    end
  end
def check_if_map_can_be_deleted if logged_in? and ( current_user . own_this_map? ( params [ :id ] ) or current_user . has_role? ( "editor" ) ) @map = Map . find ( params [ :id ] ) else flash [ :notice ] = "Sorry, you cannot delete other people's maps!" redirect_to map_path end end
only allow deleting by a user if the user owns it
only allow deleting by a user if the user owns it