Module: SimpleAttachments::AttachmentsController::Helpers

Defined in:
lib/simple_attachments/attachments_controller.rb

Instance Method Summary collapse

Instance Method Details

#attachment_controller(options = {}) ⇒ Object

Mark controller as controller for attachment resource.

Just put at any place of your controller.

attachment_controller

Sometimes you have to specify your resource manually.

attachment_controller :resource => MyNamespace::Attachment


15
16
17
18
19
20
# File 'lib/simple_attachments/attachments_controller.rb', line 15

def attachment_controller(options = {})
  before_filter :load_attachment, :except => :create
  self.class.send(:attr_accessor, :attachment_model)
  self.attachment_model = (options[:resource] or controller_path.classify.constantize)
  send :include, InstanceMethods
end