Sha256: 1e2f810f0ee67910fdafb46b992a4e45cd0ff64d2ef7d45c15612826f0ad6c29

Contents?: true

Size: 1.43 KB

Versions: 14

Compression:

Stored size: 1.43 KB

Contents

require_dependency "apidae/application_controller"

module Apidae
  class SelectionsController < ApplicationController
    before_action :set_selection, only: [:show, :edit, :update, :destroy, :refresh]

    def index
      @selections = Selection.all
    end

    def show
    end

    def new
      @selection = Selection.new
    end

    def edit
    end

    def create
      @selection = Selection.new(selection_params)

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

    def update
      if @selection.update(selection_params)
        redirect_to @selection, notice: 'Selection was successfully updated.'
      else
        render :edit
      end
    end

    def destroy
      @selection.destroy
      redirect_to selections_url, notice: 'Selection was successfully destroyed.'
    end

    def refresh
      referrer = (session.delete(:referrer) || selections_url)
      if @selection && @selection.add_or_refresh_objs
        redirect_to referrer, notice: "La sélection a bien été mise à jour."
      else
        redirect_to referrer, alert: "Une erreur s'est produite lors de la mise à jour de la sélection."
      end
    end

    private
      def set_selection
        @selection = Selection.find(params[:id])
      end

      def selection_params
        params.require(:selection).permit(:label, :reference, :apidae_id)
      end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
apidae-0.9.34 app/controllers/apidae/selections_controller.rb
apidae-0.9.33 app/controllers/apidae/selections_controller.rb
apidae-0.9.32 app/controllers/apidae/selections_controller.rb
apidae-0.9.31 app/controllers/apidae/selections_controller.rb
apidae-0.9.30 app/controllers/apidae/selections_controller.rb
apidae-0.9.29 app/controllers/apidae/selections_controller.rb
apidae-0.9.28 app/controllers/apidae/selections_controller.rb
apidae-0.9.27 app/controllers/apidae/selections_controller.rb
apidae-0.11.0 app/controllers/apidae/selections_controller.rb
apidae-0.10.0 app/controllers/apidae/selections_controller.rb
apidae-0.9.26 app/controllers/apidae/selections_controller.rb
apidae-0.9.25 app/controllers/apidae/selections_controller.rb
apidae-0.9.24 app/controllers/apidae/selections_controller.rb
apidae-0.9.23 app/controllers/apidae/selections_controller.rb