Sha256: d33b64b0d371337c199537ab89763610bfb24aaeb501ef2b30fdf768f6599a72

Contents?: true

Size: 1.97 KB

Versions: 11

Compression:

Stored size: 1.97 KB

Contents

class DemandsController < ApplicationController
  load_and_authorize_resource

  # GET /demands
  # GET /demands.json
  def index
    @demands = Demand.order('id DESC').page(params[:page])

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @demands }
    end
  end

  # GET /demands/1
  # GET /demands/1.json
  def show
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @demand }
      format.txt
    end
  end

  # GET /demands/new
  # GET /demands/new.json
  def new
    @demand = Demand.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @demand }
    end
  end

  # GET /demands/1/edit
  def edit
  end

  # POST /demands
  # POST /demands.json
  def create
    @demand = Demand.new(demand_params)

    respond_to do |format|
      if @demand.save
        format.html { redirect_to @demand, notice: t('statistic.successfully_created', model: t('activerecord.models.demand')) }
        format.json { render json: @demand, status: :created, location: @demand }
      else
        format.html { render action: "new" }
        format.json { render json: @demand.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /demands/1
  # PUT /demands/1.json
  def update
    respond_to do |format|
      if @demand.update_attributes(demand_params)
        format.html { redirect_to @demand, notice: t('controller.successfully_updated', model: t('activerecord.models.demand')) }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @demand.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /demands/1
  # DELETE /demands/1.json
  def destroy
    @demand.destroy

    respond_to do |format|
      format.html { redirect_to demands_url }
      format.json { head :no_content }
    end
  end

  private
  def demand_params
    params.fetch(:demand, {}).permit()
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
enju_circulation-0.1.2 app/controllers/demands_controller.rb
enju_circulation-0.1.1 app/controllers/demands_controller.rb
enju_circulation-0.1.0 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre49 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre48 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre47 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre46 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre45 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre44 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre43 app/controllers/demands_controller.rb
enju_circulation-0.1.0.pre42 app/controllers/demands_controller.rb