Module: SocialStream::Controllers::Helpers::ClassMethods

Defined in:
lib/social_stream/controllers/helpers.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to_subjects(options = {}) ⇒ Object

Add to controllers that have nested subjects. Examples are:

class ProfilesController < InheritedResources::Base
  belongs_to_subjects(:singleton => true) # provides /users/demo/profile
end

class ActivitiesController < InheritedResources::Base
  belongs_to_subjects # provides /users/demo/activities
end


25
26
27
28
29
30
31
# File 'lib/social_stream/controllers/helpers.rb', line 25

def belongs_to_subjects(options = {})
  opts = { :polymorphic => true, :finder => :find_by_slug! }.update(options)

  args = SocialStream.subjects + [ opts ]

  belongs_to *args
end