Sha256: 3034f14b49694189eee3db0fd2d72b830eb285246693783719ccbfedd8c3ef19

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 Bytes

Contents

class Manage::PostsController < Manage::BaseController
  inherit_resources
  
  belongs_to :structure
  
  before_filter :make_filter, :only => [:index]
  
  defaults :route_prefix => 'manage'
  actions :all, :except => [:show]
  
  cache_sweeper :post_sweeper, :only => [:create, :update, :destroy]
  
  def create
    create!{ manage_structure_posts_path(@structure.id) }
  end
  
  def update
    update!{ manage_structure_posts_path(@structure.id) }
  end
  
  def destroy
    destroy!{ manage_structure_posts_path(@structure.id) }
  end
  
  protected
    
    def begin_of_association_chain
      @structure
    end
    
    def collection
      options = { :page => params[:page], :per_page => 20 }
      options.update @search.filter
      
      @posts ||= end_of_association_chain.paginate(options)
    end
    
    def make_filter
      @search = Freeberry::ModelFilter.new(Post, :attributes=>[ :title, :kind ] )
      @search.update_attributes(params[:search])
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
freeberry-0.2.7 app/controllers/manage/posts_controller.rb
freeberry-0.2.6 app/controllers/manage/posts_controller.rb
freeberry-0.2.5 app/controllers/manage/posts_controller.rb