Update README re #search method name conflicts.
TODO: allow opting-out of `alias :search :ransack` in the Ransack config/initializer file. [skip ci]
This commit is contained in:
parent
f858dd6d98
commit
5c7bb9eaf3
13
README.md
13
README.md
|
@ -229,13 +229,24 @@ construct much more complex search forms, such as the one on the
|
|||
|
||||
Ransack will try to to make `#search` available in your models, but in the case
|
||||
that `#search` has already been defined, you can use `#ransack` instead. For
|
||||
example the following would be equivalent:
|
||||
example, the following would be equivalent:
|
||||
|
||||
```ruby
|
||||
Article.search(params[:q])
|
||||
Article.ransack(params[:q])
|
||||
```
|
||||
|
||||
If Ransack's `#search` method conflicts with the name of another method named
|
||||
`search` in your code or another gem, it may be resolved either by patching
|
||||
the `extended` class_method in `Ransack::Adapters::ActiveRecord::Base` to
|
||||
remove the line `alias :search :ransack unless base.respond_to? :search`, or by
|
||||
placing the following line in your Ransack initializer file at
|
||||
`config/initializers/ransack.rb`:
|
||||
|
||||
```ruby
|
||||
Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
|
||||
```
|
||||
|
||||
### Associations
|
||||
|
||||
You can easily use Ransack to search for objects in `has_many` and `belongs_to`
|
||||
|
|
Loading…
Reference in New Issue