Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Define Rails3ClassMethods so that named_scope is not called in active…
Browse files Browse the repository at this point in the history
…record 3
  • Loading branch information
rickbutton committed Dec 6, 2013
1 parent 1d22e08 commit 5fb73c1
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/fuzzily/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ module Rails2ClassMethods

def self.extended(base)
base.class_eval do
named_scope :offset,
lambda { |*args| { :offset => args.first } } if respond_to? :named_scope
named_scope :offset, lambda { |*args| { :offset => args.first } }
end
end

Expand All @@ -160,7 +159,26 @@ def _with_included_trigrams(_o)
end
end

Rails3ClassMethods = Rails2ClassMethods
module Rails3ClassMethods
include ClassMethods

private

def _add_trigram_association(_o)
has_many _o.trigram_association,
:class_name => _o.trigram_class_name,
:as => :owner,
:conditions => { :fuzzy_field => _o.field.to_s },
:dependent => :destroy,
:autosave => true
end

def _with_included_trigrams(_o)
self.scoped(:include => _o.trigram_association)
end
end



module Rails4ClassMethods
include ClassMethods
Expand Down

0 comments on commit 5fb73c1

Please sign in to comment.