fix:some bug
This commit is contained in:
parent
73373fbff4
commit
29c2082605
|
@ -1,6 +1,5 @@
|
|||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
require 'acts_as_able/version'
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
|
@ -30,5 +29,5 @@ Gem::Specification.new do |spec|
|
|||
spec.add_development_dependency "bundler", "~> 1.16"
|
||||
spec.add_development_dependency "rake", "~> 10.0"
|
||||
spec.add_development_dependency "rspec", "~> 3.0"
|
||||
spec.add_development_dependency "rails", "~> 5.0"
|
||||
spec.add_development_dependency "rails", "~> 6.0"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
$:.unshift "#{File.dirname(__FILE__)}/lib"
|
||||
require "acts_as_able"
|
|
@ -1,15 +1,23 @@
|
|||
require "acts_as_able/version"
|
||||
|
||||
module ActsAsFollowable
|
||||
module ActsAsAble
|
||||
extend ActiveSupport::Autoload
|
||||
autoload :AbleExt, 'acts_as_able/able_ext'
|
||||
autoload :Followable, 'acts_as_able/followable'
|
||||
autoload :Follower, 'acts_as_able/follower'
|
||||
autoload :Unlikable, 'acts_as_able/unlikable'
|
||||
autoload :Unliker, 'acts_as_able/unliker'
|
||||
autoload :Viewable, 'acts_as_able/viewable'
|
||||
autoload :Viewer, 'acts_as_able/viewer'
|
||||
|
||||
# require 'acts_as_followable/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
include ActsAsAble::Followable
|
||||
include ActsAsAble::Follower
|
||||
include ActsAsAble::Unlikable
|
||||
include ActsAsAble::Unliker
|
||||
include ActsAsAble::Viewable
|
||||
include ActsAsAble::Viewer
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@ module ActsAsAble
|
|||
module ClassMethods
|
||||
# Those call this method has the ability to be unlike by others
|
||||
def acts_as_unlikable
|
||||
include ActAsAble::AbleExt
|
||||
include ActsAsAble::AbleExt
|
||||
has_many :unlikers, as: :unlikable, dependent: :destroy, class_name: 'Unlike'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,9 +7,9 @@ module ActsAsAble
|
|||
end
|
||||
|
||||
module ClassMethods
|
||||
# Those call this method has the ability to be unlike by others
|
||||
# Those call this method has the ability to be unlike by others
|
||||
def acts_as_viewable
|
||||
include ActAsAble::AbleExt
|
||||
include ActsAsAble::AbleExt
|
||||
has_many :viewers, as: :viewable, dependent: :destroy, class_name: 'View'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ module ActsAsAble
|
|||
|
||||
# 是否不喜欢某对象
|
||||
def view?(obj)
|
||||
!unlike_by(obj).blank?
|
||||
!view_by(obj).blank?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
require "acts_as_able/version"
|
||||
|
||||
module ActsAsUnlikeable
|
||||
extend ActiveSupport::Autoload
|
||||
autoload :AbleExt, 'acts_as_able/able_ext'
|
||||
autoload :Unlikable, 'acts_as_able/unlikable'
|
||||
autoload :Unliker, 'acts_as_able/unliker'
|
||||
|
||||
# require 'acts_as_followable/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
include ActsAsAble::Unlikable
|
||||
include ActsAsAble::Unliker
|
||||
end
|
||||
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
require "acts_as_able/version"
|
||||
|
||||
module ActsAsViewable
|
||||
extend ActiveSupport::Autoload
|
||||
autoload :AbleExt, 'acts_as_able/able_ext'
|
||||
autoload :Viewable, 'acts_as_able/viewable'
|
||||
autoload :Viewer, 'acts_as_able/viewer'
|
||||
|
||||
# require 'acts_as_followable/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
include ActsAsAble::Viewable
|
||||
include ActsAsAble::Viewer
|
||||
end
|
||||
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'generators/acts_as_able_generator'
|
||||
|
||||
class ActsAsUnlikeableGenerator < ActsAsAbleGenerator
|
||||
class ActsAsUnlikableGenerator < ActsAsAbleGenerator
|
||||
def create_migration_file
|
||||
migration_template 'unlike_migration.rb', 'db/migrate/acts_as_unlikable_migration.rb'
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'generators/acts_as_able_generator'
|
||||
|
||||
class ActsAsUnlikeableGenerator < ActsAsAbleGenerator
|
||||
class ActsAsViewableGenerator < ActsAsAbleGenerator
|
||||
def create_migration_file
|
||||
migration_template 'view_migration.rb', 'db/migrate/acts_as_viewable_migration.rb'
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class ActsAsUnlikableMigration < ActiveRecord::Migration[5.0]
|
||||
class ActsAsViewableMigration < ActiveRecord::Migration[5.0]
|
||||
def self.up
|
||||
create_table :views, force: true do |t|
|
||||
t.references :viewable, polymorphic: true, null: false
|
||||
|
|
Loading…
Reference in New Issue