Sha256: 252fdda2937a4fee1a5d0a5e6c4bacfb5b7d255aa8dde399c33ca6ffbf00cd15

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require_dependency "smithy/base_controller"

module Smithy
  class AssetsController < BaseController
    before_filter :load_assets, :only => :index
    respond_to :html, :json, :js

    def index
      respond_with @assets, :layout => 'smithy/wide'
    end

    def new
      @asset = Asset.new(params[:asset])
      respond_with @asset
    end

    def create
      @asset = Asset.new(params[:asset])
      @asset.save
      flash.notice = "Your asset was created" if @asset.persisted?
      respond_with @asset do |format|
        format.html { redirect_to assets_path }
      end
    end

    def edit
      @asset = Asset.find(params[:id])
      respond_with @asset
    end

    def update
      @asset = Asset.find(params[:id])
      flash.notice = "Your asset was saved" if @asset.update_attributes(params[:asset])
      respond_with @asset do |format|
        format.html { redirect_to assets_path }
      end
    end

    def destroy
      @asset = Asset.find(params[:id])
      @asset.destroy
      respond_with @asset
    end

    private
      def load_assets
        @assets = Asset.order(:name).page(params[:page])
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smithycms-0.0.3 app/controllers/smithy/assets_controller.rb
smithycms-0.0.2 app/controllers/smithy/assets_controller.rb
smithycms-0.0.1 app/controllers/smithy/assets_controller.rb