Go to file
vilet.yy 29c2082605 fix:some bug 2021-05-17 11:19:09 +08:00
bin fix: extend relation 2021-05-14 17:46:45 +08:00
lib fix:some bug 2021-05-17 11:19:09 +08:00
spec fix: remname namespace 2021-05-14 16:38:45 +08:00
.gitignore init followable gem 2016-06-20 12:12:09 +08:00
.rspec init followable gem 2016-06-20 12:12:09 +08:00
.travis.yml init followable gem 2016-06-20 12:12:09 +08:00
CODE_OF_CONDUCT.md init followable gem 2016-06-20 12:12:09 +08:00
Gemfile init followable gem 2016-06-20 12:12:09 +08:00
LICENSE.txt init followable gem 2016-06-20 12:12:09 +08:00
README.md fix: remname namespace 2021-05-14 16:38:45 +08:00
Rakefile init followable gem 2016-06-20 12:12:09 +08:00
acts_as_able.gemspec fix:some bug 2021-05-17 11:19:09 +08:00
init.rb fix:some bug 2021-05-17 11:19:09 +08:00

README.md

ActsAsFollowable

这就是一个给国人用的 关注、浏览、点赞等有关的 Gem

Installation

Add this line to your application's Gemfile:

gem 'acts_as_able', git: 'git://github.com/viletyy/acts_as_able.git'

And then execute:

$ bundle

Usage

关注功能

rails g acts_as_followable
rails db:migrate

以下方法可以放在需要使用的类中:

acts_as_followable  #被关注
acts_as_follower    #关注者


class Article < ApplicationRecord
  acts_as_followable
end

class User < ApplicationRecord
  acts_as_follower
end

acts_as_followable

acts_as_followable

#找出某个模型关注我的所有的对象
Article.followers_by_type(User)

acts_as_follower

acts_as_follower

# 关注某个模型的某个对象
User.first.follow(Article.first)
# 万恶的取关
User.first.unfollow(Article.first)
# 查看是否关注某个对象
User.first.follow?(Article.first)
# 查看关注模型的所有对象
User.first.followings(Article)

以上是目前实现的功能 还有黑名单等功能待实现

License

The gem is available as open source under the terms of the MIT License.