acts_as_followable 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +28 -7
- data/lib/acts_as_followable/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -17,12 +17,7 @@ Run the generator which will generate a migration file.
|
|
17
17
|
script/generate acts_as_followable
|
18
18
|
|
19
19
|
The plugin comes with a Follow model file. You can override the default model definition by creating a new
|
20
|
-
app/models/follow.rb file
|
21
|
-
|
22
|
-
class Follow < ActiveRecord::Base
|
23
|
-
belongs_to :followable, :polymorphic => true
|
24
|
-
belongs_to :follower, :polymorphic => true
|
25
|
-
end
|
20
|
+
app/models/follow.rb file. You can copy the content of a model from {here}[https://github.com/xpepermint/acts_as_followable/blob/master/app/models/follow.rb].
|
26
21
|
|
27
22
|
== Setup
|
28
23
|
|
@@ -32,7 +27,7 @@ If you would like a model to follow or to be followed by any other model, just a
|
|
32
27
|
acts_as_followable
|
33
28
|
...
|
34
29
|
end
|
35
|
-
|
30
|
+
|
36
31
|
== Examples
|
37
32
|
|
38
33
|
To have an object start following another use the following:
|
@@ -84,3 +79,29 @@ To get a list of records of a particular type which this record is following (e.
|
|
84
79
|
user.following_by_type('Book').limit(2)
|
85
80
|
or
|
86
81
|
user.following_book('title')
|
82
|
+
|
83
|
+
You can also query Follow model records like this:
|
84
|
+
|
85
|
+
# What user is following
|
86
|
+
user.follows
|
87
|
+
user.follows.limit(1)
|
88
|
+
|
89
|
+
# Who follows a book
|
90
|
+
book.followings
|
91
|
+
book.followings.order('created_at')
|
92
|
+
|
93
|
+
# Follow records by follower type
|
94
|
+
Follow.for_follower_type('User')
|
95
|
+
Follow.for_follower_type('User').limit(1)
|
96
|
+
|
97
|
+
# Follow records by followable type
|
98
|
+
Follow.for_followable_type('Book')
|
99
|
+
Follow.for_followable_type('Book').order('created_at')
|
100
|
+
|
101
|
+
# Follow records from follower
|
102
|
+
Follow.for_follower(user)
|
103
|
+
Follow.for_follower(user).limit(1)
|
104
|
+
|
105
|
+
# Follow records from followable
|
106
|
+
Follow.for_followable(book)
|
107
|
+
Follow.for_followable(book).order('created_at')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_followable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kristijan Sedlak
|