Sha256: 628b92ee6439aa28d484bbcba6b301d6af9ff657e52234b57da4878689da9a3c

Contents?: true

Size: 789 Bytes

Versions: 2

Compression:

Stored size: 789 Bytes

Contents

module Adhoq
  class QueriesController < Adhoq::ApplicationController
    def index
      @queries = Adhoq::Query.recent_first
    end

    def show
      @query = Adhoq::Query.find(params[:id])
    end

    def new
      @query = Adhoq::Query.new
    end

    def create
      @query = Adhoq::Query.create!(query_attributes)

      redirect_to @query
    end

    def edit
      @query = Adhoq::Query.find(params[:id])
    end

    def update
      @query = Adhoq::Query.find(params[:id])
      @query.update!(query_attributes)

      redirect_to @query
    end

    def destroy
      Adhoq::Query.find(params[:id]).destroy!
      redirect_to action: :index
    end

    private

    def query_attributes
      params.require(:query).permit(:name, :description, :query)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adhoq-1.0.2 app/controllers/adhoq/queries_controller.rb
adhoq-1.0.1 app/controllers/adhoq/queries_controller.rb