acts_as_followable 0.1.2 → 0.1.3
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 +8 -3
- data/lib/acts_as_followable/followable.rb +5 -0
- data/lib/acts_as_followable/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -14,7 +14,8 @@ Add this line to your Gemfile (and run bundle install):
|
|
14
14
|
|
15
15
|
Run the generator which will generate a migration file.
|
16
16
|
|
17
|
-
|
17
|
+
rails g acts_as_followable
|
18
|
+
rake db:migrate
|
18
19
|
|
19
20
|
The plugin comes with a Follow model file. You can override the default model definition by creating a new
|
20
21
|
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].
|
@@ -36,10 +37,14 @@ To have an object start following another use the following:
|
|
36
37
|
user = User.find(1)
|
37
38
|
user.follow(book)
|
38
39
|
|
39
|
-
To stop following an object use the following
|
40
|
+
To stop following an object use the following:
|
40
41
|
|
41
42
|
user.stop_following(book)
|
42
|
-
|
43
|
+
|
44
|
+
You can remove all the followers like this:
|
45
|
+
|
46
|
+
user.remove_followers_by_type('Book')
|
47
|
+
|
43
48
|
You can check to see if an object is following another object through the following:
|
44
49
|
|
45
50
|
user.following?(book)
|
@@ -63,6 +63,11 @@ module ActsAsFollowable
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
# Destroys all followers of a given type
|
67
|
+
def remove_followers_by_type(type)
|
68
|
+
Follow.where(['follows.followable_id=? AND follows.followable_type=? AND follows.follower_type=?', self.id, self.class.name, type]).destroy_all
|
69
|
+
end
|
70
|
+
|
66
71
|
# Returns true if the current instance is followed by the passed record
|
67
72
|
def followed_by?(follower)
|
68
73
|
0 < follow_for_follower(follower).limit(1).count
|
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kristijan Sedlak
|