Sha256: 2496b62e4b6a6cb3b8e7e54669d59d1f5efe57feed666af2bd3747cea3444d9c

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

require_dependency "binda/application_controller"

module Binda
  class AssetsController < ApplicationController
    before_action :set_asset, only: [:show, :edit, :update, :destroy, :remove_image]

    # GET /assets
    def index
      @assets = Asset.all
    end

    # GET /assets/1
    def show
    end

    # GET /assets/new
    def new
      @asset = Asset.new
    end

    # GET /assets/1/edit
    def edit
    end

    # POST /assets
    def create
      @asset = Asset.new(asset_params)

      if @asset.save
        redirect_to asset_path( @asset.id ), notice: 'Asset was successfully created.'
      else
        render :new
      end
    end

    # PATCH/PUT /assets/1
    def update
      if @asset.update(asset_params)
        redirect_to asset_path( @asset.id ), notice: 'Asset was successfully updated.'
      else
        render :edit
      end
    end

    # DELETE /assets/1
    def destroy
      @asset.destroy
      redirect_to assets_url, notice: 'Asset was successfully destroyed.'
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_asset
        @asset = Asset.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def asset_params
        params.require(:asset).permit( :image, :name )
      end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
binda-0.1.11 app/controllers/binda/assets_controller.rb
binda-0.1.10 app/controllers/binda/assets_controller.rb
binda-0.1.9 app/controllers/binda/assets_controller.rb
binda-0.1.8 app/controllers/binda/assets_controller.rb
binda-0.1.7 app/controllers/binda/assets_controller.rb
binda-0.1.6 app/controllers/binda/assets_controller.rb
binda-0.1.5 app/controllers/binda/assets_controller.rb
binda-0.1.4 app/controllers/binda/assets_controller.rb
binda-0.1.3 app/controllers/binda/assets_controller.rb
binda-0.1.2 app/controllers/binda/assets_controller.rb
binda-0.1.1 app/controllers/binda/assets_controller.rb
binda-0.1.0 app/controllers/binda/assets_controller.rb