Sha256: 4700bf0b67ab00c71589f79ea7412739f84e85c356c620cc7dae8559ea8d7fdf

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

module Puffer
  class Base < ApplicationController
    unloadable
    pufferize!

    before_filter :require_puffer_user

    define_fieldset :index, :form
    define_fieldset :show, :fallbacks => :index
    define_fieldset :create, :update, :fallbacks => :form

    respond_to :html, :js

    def index
      @records = resource.collection.page(params[:page])
    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

    def event
      render :text => fields(params[:fieldset])[params[:field]].render(self, params[:event])
    end

  private

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puffer-0.0.32 app/controllers/puffer/base.rb
puffer-0.0.31 app/controllers/puffer/base.rb
puffer-0.0.30 app/controllers/puffer/base.rb