Module: Acts::ArchiveController::Archived

Defined in:
lib/acts_as_archive_controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) acts_as_archive_controller(model_name, options = {})

Mixes-in the behaviour for a controller surrounding a archive resource specified with ActsAsArchive By default only adds read actions (show, index)

Parameters

  • model_name singular model name as string or symbol

Options

  • allow_create Add create and new actions

  • allow_update Add update and edit actions



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/acts_as_archive_controller.rb', line 188

def acts_as_archive_controller(model_name, options = {})
  extend ClassMethods

  prepend_before_filter :find_parent_node, :only => [ :new, :create ]
  before_filter :find_record,              :only => [ :show, :edit, :update ]
  before_filter :set_commit_type,          :only => [ :create, :update ]
  before_filter :parse_date_parameters,    :only => [ :index ]
  layout false

  self.singular_name      = model_name.to_s
  self.content_class_name = singular_name.camelize
  self.date_attribute     = options[:date_attribute] || :created_at
  self.render_weeks       = options[:render_weeks]   || false

  include InstanceMethods
  include CreateMethods unless options[:allow_create] == false
  include UpdateMethods unless options[:allow_update] == false
end