Module: Motr::Controller::CargoHelpers::ClassMethods

Defined in:
lib/motr/controller/cargo_helpers.rb

Instance Method Summary collapse

Instance Method Details

#delivers_cargoObject

Normally you would have your controllers extend Motr::CargoController, in the event this isn’t possible, calling delivers_cargo will ensure the proper functionality exists.



36
37
38
# File 'lib/motr/controller/cargo_helpers.rb', line 36

def delivers_cargo
  include Motr::Cargo::Delivery
end

#delivers_cargo_for(*resources) ⇒ Object

Configures models a particular controller “delivers”. By default cargo considers the controller name to be the resource name that it is to serve. Calling delivers_cargo_for allows the controller to find objects based on object_id parameters.

Examples:

Configure a Posts controller to deliver resources for Blog and Article

class PostsController < Motr::CargosController
  delivers_cargo_for :blog, :article
end

Parameters:

  • *resources (Symbol, Array)

    The resources/models this controller delivers



26
27
28
29
# File 'lib/motr/controller/cargo_helpers.rb', line 26

def delivers_cargo_for(*resources)
  options = resources.extract_options!
  self.motr_cargo_classes |= resources          
end