Skip to content

Commit edaf306

Browse files
committed
Remove deprecated #search method
`#search` is deprecated in v2.1.1 and it scheduled to remove the method in v2.3. #975 But the method still exists in v2.3.2. So let's remove the method. If we removed the method, users can remove the patch for `search` (`ActiveRecord::Base.class_eval('remove_method :search'`).
1 parent a5feb0a commit edaf306

File tree

3 files changed

+0
-29
lines changed

3 files changed

+0
-29
lines changed

README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -352,32 +352,6 @@ construct much more complex search forms, such as the one on the
352352
[demo app](http://ransack-demo.herokuapp.com/users/advanced_search)
353353
(source code [here](https://github.com/activerecord-hackery/ransack_demo)).
354354

355-
### Ransack #search method
356-
357-
Ransack will try to make the class method `#search` available in your
358-
models, but if `#search` has already been defined elsewhere, you can always use
359-
the default `#ransack` class method. So the following are equivalent:
360-
361-
```ruby
362-
Article.ransack(params[:q])
363-
Article.search(params[:q])
364-
```
365-
366-
Users have reported issues of `#search` name conflicts with other gems, so
367-
the `#search` method alias will be deprecated in the next major version of
368-
Ransack (2.0). It's advisable to use the default `#ransack` instead.
369-
370-
For now, if Ransack's `#search` method conflicts with the name of another
371-
method named `search` in your code or another gem, you may resolve it either by
372-
patching the `extended` class_method in `Ransack::Adapters::ActiveRecord::Base`
373-
to remove the line `alias :search :ransack unless base.respond_to? :search`, or
374-
by placing the following line in your Ransack initializer file at
375-
`config/initializers/ransack.rb`:
376-
377-
```ruby
378-
Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
379-
```
380-
381355
### Associations
382356

383357
You can easily use Ransack to search for objects in `has_many` and `belongs_to`

lib/ransack/adapters/active_record/base.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module ActiveRecord
44
module Base
55

66
def self.extended(base)
7-
alias :search :ransack unless base.respond_to? :search
87
base.class_eval do
98
class_attribute :_ransackers
109
class_attribute :_ransack_aliases
@@ -14,7 +13,6 @@ def self.extended(base)
1413
end
1514

1615
def ransack(params = {}, options = {})
17-
ActiveSupport::Deprecation.warn("#search is deprecated and will be removed in 2.3, please use #ransack instead") if __callee__ == :search
1816
Search.new(self, params, options)
1917
end
2018

spec/ransack/adapters/active_record/base_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module ActiveRecord
88
subject { ::ActiveRecord::Base }
99

1010
it { should respond_to :ransack }
11-
it { should respond_to :search }
1211

1312
describe '#search' do
1413
subject { Person.ransack }

0 commit comments

Comments
 (0)