class LocationsController < ApplicationController before_action :set_location, only: [:show, :edit, :update, :destroy] # GET /locations def index @locations = Location.all end # GET /locations/1 def show end # GET /locations/new def new @location = Location.new end # GET /locations/1/edit def edit end # POST /locations def create @location = Location.new(location_params) if @location.save redirect_to @location, notice: 'Location was successfully created.' else render action: 'new' end end # PATCH/PUT /locations/1 def update if @location.update(location_params) redirect_to @location, notice: 'Location was successfully updated.' else render action: 'edit' end end # DELETE /locations/1 def destroy @location.destroy redirect_to locations_url, notice: 'Location was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_location @location = Location.find(params[:id]) end # Only allow a trusted parameter "white list" through. def location_params params.require(:location).permit(:title, :address, :latitude, :longitude) end end