Commit 29cd6905 by Rocky Duan

still working

parent 0ce290be
......@@ -29,7 +29,7 @@ class CommentThread
end
def subscribers
subscriptions.map{|s| User.find(s.subscriber_id)}
subscriptions.map(&:subscriber)
end
def to_hash(params={})
......
......@@ -20,7 +20,7 @@ class Commentable
end
def subscribers
subscriptions.map{|s| User.find(s.subscriber_id)}
subscriptions.map(&:subscriber)
end
def to_hash(params={})
......
......@@ -2,9 +2,8 @@ class Subscription
include Mongoid::Document
include Mongoid::Timestamps
field :subscriber_id, type: String
field :source_id, type: String
field :source_type, type: String
belongs_to :subscriber, class_name: "User", autosave: true
belongs_to :source, polymorphic: true, autosave: true
index [[:subscriber_id, Mongo::ASCENDING], [:source_id, Mongo::ASCENDING], [:source_type, Mongo::ASCENDING]]
index [[:source_id, Mongo::ASCENDING], [:source_type, Mongo::ASCENDING]]
......
......@@ -25,7 +25,7 @@ class User
end
def followers
follower_subscriptions.map{|s| User.find(s.subscriber_id)}
follower_subscriptions.map(&:subscriber)
end
def subscribe(source)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment