Sha256: e422f680dfe54cfa0072cec3ffa53d8393c64cd933af1613f417aac42dfde5ef
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
class Group < ActiveRecord::Base attr_accessor :_founder attr_accessor :_participants delegate :description, :description=, :to => :profile! after_create :create_founder after_create :create_participants def profile! actor!.profile || actor!.build_profile end def followers contacts(:subject_type => :user, :direction => :received) end def recent_groups contacts(:type => :group, :direction => :sent) do |q| q.select("ties.created_at"). merge(Tie.recent) end end private #Creates the ties between the group and the founder def create_founder founder = Actor.find_by_slug(_founder) || raise("Cannot create group without founder") sent_ties.create! :receiver => founder, :relation => relation_customs.sort.first end #Creates the ties betwbeen the group and the participants def create_participants return if @_participants.blank? @_participants.each do |participant| participant_actor = Actor.find_by_slug!(participant) sent_ties.create! :receiver => participant_actor, :relation => relation_customs.sort.first end end end
Version data entries
5 entries across 5 versions & 2 rubygems