tophold_engine 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/sub_topic.rb +11 -1
- data/app/models/tag.rb +3 -3
- data/app/models/user.rb +0 -2
- data/lib/tophold_engine/version.rb +1 -1
- metadata +1 -1
data/app/models/sub_topic.rb
CHANGED
@@ -6,8 +6,18 @@ class SubTopic
|
|
6
6
|
|
7
7
|
field :content, type: String
|
8
8
|
|
9
|
-
|
9
|
+
field :creator_id, type: Integer
|
10
10
|
|
11
11
|
belongs_to :topic
|
12
12
|
|
13
|
+
def creator
|
14
|
+
return nil if self.creator_id.blank?
|
15
|
+
User.find self.creator_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def creator= u
|
19
|
+
return unless u.is_a?(User)
|
20
|
+
self.creator_id = u.id
|
21
|
+
end
|
22
|
+
|
13
23
|
end
|
data/app/models/tag.rb
CHANGED
@@ -7,10 +7,10 @@ class Tag
|
|
7
7
|
|
8
8
|
recursively_embeds_many
|
9
9
|
|
10
|
-
embedded_in :article,
|
10
|
+
embedded_in :article, polymorphic: true
|
11
11
|
|
12
|
-
embedded_in :topic,
|
12
|
+
embedded_in :topic, polymorphic: true
|
13
13
|
|
14
|
-
embedded_in :sub_topic,
|
14
|
+
embedded_in :sub_topic, polymorphic: true
|
15
15
|
|
16
16
|
end
|
data/app/models/user.rb
CHANGED