Sha256: 6e6e4c511f91e8f2754a94bc5b260b9a2683676cd7867749336e9e790ae7e20d

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

module Puffer
  class Base < ApplicationController
    unloadable

    pufferize!
    define_fields :index, :show, :form, :create, :update

    respond_to :html, :js

    def index
      @records = resource.collection
    end

    def show
      @record = resource.member
    end

    def new
      @record = resource.new_member
    end

    def edit
      @record = resource.member
    end

    def create
      @record = resource.new_member
      @record.save
      respond_with @record, :location => puffer_saving_location
    end

    def update
      @record = resource.member
      @record.update_attributes resource.attributes
      respond_with @record, :location => puffer_saving_location
    end

    def destroy
      @record = resource.member
      @record.destroy
      redirect_to (request.referrer || resource.collection_path)
    end

  private

    def puffer_saving_location
      params[:commit] == t('puffer.save') ? resource.edit_path(record) : resource.collection_path
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puffer-0.0.20 lib/puffer/base.rb