Sha256: b3f1fc5157890d2803fcb68f29c8d53988653375cf721ba71c413e6a650d19d8

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

class PlacesController < ApplicationController
  before_action :set_place, only: [:show, :edit, :update, :destroy]
  before_action :check_policy, only: [:index, :new, :create]

  # GET /places
  def index
    @places = Place.all
  end

  # GET /places/1
  def show
  end

  # GET /places/new
  def new
    @place = Place.new
  end

  # GET /places/1/edit
  def edit
  end

  # POST /places
  def create
    @place = Place.new(place_params)

    if @place.save
      redirect_to @place, notice: 'Place was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /places/1
  def update
    if @place.update(place_params)
      redirect_to @place, notice: 'Place was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /places/1
  def destroy
    @place.destroy
    redirect_to places_url, notice: 'Place was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
  def set_place
    @place = Place.find(params[:id])
    autorize @place
  end

  def check_policy
    authorize Place
  end

    # Only allow a trusted parameter "white list" through.
  def place_params
    params.require(:place).permit(:term, :city, :country_id, :latitude, :longitude)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
enju_event-0.4.0.rc.1 app/controllers/places_controller.rb
enju_event-0.3.4 app/controllers/places_controller.rb
enju_event-0.3.3 app/controllers/places_controller.rb
enju_event-0.4.0.beta.2 app/controllers/places_controller.rb
enju_event-0.4.0.beta.1 app/controllers/places_controller.rb
enju_event-0.3.2 app/controllers/places_controller.rb
enju_event-0.3.1 app/controllers/places_controller.rb
enju_event-0.3.0 app/controllers/places_controller.rb
enju_event-0.3.0.rc.1 app/controllers/places_controller.rb
enju_event-0.3.0.beta.1 app/controllers/places_controller.rb