From 3164e5a59bf2609a26e3f765f9d6252409b8c1df Mon Sep 17 00:00:00 2001 From: ZengTao Date: Wed, 22 Jun 2016 11:52:42 +0800 Subject: [PATCH] railtie to rails --- lib/acts_as_followable.rb | 2 ++ lib/acts_as_followable/railtie.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 lib/acts_as_followable/railtie.rb diff --git a/lib/acts_as_followable.rb b/lib/acts_as_followable.rb index 3685b06..334b40b 100644 --- a/lib/acts_as_followable.rb +++ b/lib/acts_as_followable.rb @@ -4,4 +4,6 @@ module ActsAsFollowable autoload :Followable, 'acts_as_followable/followable' # autoload :Follower, 'acts_as_followable/follower' autoload :FollowExt, 'acts_as_followable/follow_ext' + + require 'acts_as_followable/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3 end diff --git a/lib/acts_as_followable/railtie.rb b/lib/acts_as_followable/railtie.rb new file mode 100644 index 0000000..48bb9b3 --- /dev/null +++ b/lib/acts_as_followable/railtie.rb @@ -0,0 +1,15 @@ +require 'acts_as_follower' +require 'rails' + +module ActsAsFollower + class Railtie < Rails::Railtie + + initializer "acts_as_followable.active_record" do |app| + ActiveSupport.on_load :active_record do + # include ActsAsFollowable::Follower + include ActsAsFollowable::Followable + end + end + + end +end