Skip to content

Commit

Permalink
Add support for Rails 7+
Browse files Browse the repository at this point in the history
The `searchable` module broke on Rails 7 because it was explicitly looking for Rails 5 or 6. The behavior was actually the same between 5 and 6, and works the same way on Rails 7, so I've simplified the logic for which class methods to include: all of them. Rails versions older than 5.1 are already incompatible with the gemspec, so this change should keep the gem working through major version changes in the future.
  • Loading branch information
ragesoss authored and 2called-chaos committed Jul 28, 2022
1 parent 3a66df1 commit 3f143bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ with the same intent.

## Fork differences

- Added support for Rails 5.1 and 6.0
- Added support for Rails 5.1, 6, and 7
- Removed support for Rails <5.1

### Breaking changes
Expand Down
15 changes: 1 addition & 14 deletions lib/fuzzily/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ module Fuzzily
module Searchable

def self.included(by)
case ActiveRecord::VERSION::MAJOR
when 5 then by.extend Rails5ClassMethods
when 6 then by.extend Rails6ClassMethods
end
by.extend ClassMethods
end

private
Expand Down Expand Up @@ -149,12 +146,6 @@ def make_field_fuzzily_searchable(field, options={})
class_variable_set(:"@@fuzzily_searchable_#{field}", true)
self
end
end

module Rails5ClassMethods
include ClassMethods

private

def _add_trigram_association(_o)
has_many _o.trigram_association,
Expand All @@ -169,9 +160,5 @@ def _with_included_trigrams(_o)
self.includes(_o.trigram_association)
end
end

module Rails6ClassMethods
include Rails5ClassMethods
end
end
end
2 changes: 1 addition & 1 deletion lib/fuzzily/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Fuzzily
VERSION = "1.0.0"
VERSION = "1.0.1"
end

0 comments on commit 3f143bf

Please sign in to comment.