mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
Merge branch 'master' into mongoid
* master: Patch Rails commit c1a118a Remove extra space [skip ci] Use newer Ruby hash syntax [skip ci] Update change log [skip ci] Wrap 80 characters [skip ci]
This commit is contained in:
commit
bfae6b45de
3 changed files with 37 additions and 17 deletions
27
CHANGELOG.md
27
CHANGELOG.md
|
@ -3,13 +3,24 @@ This change log was started in August 2014. All notable changes to this project
|
|||
henceforth should be documented here.
|
||||
|
||||
## Master (Unreleased)
|
||||
### Added
|
||||
|
||||
### Fixed
|
||||
|
||||
* Add support for passing stringy booleans for ransackable scopes. ([pull request](https://github.com/activerecord-hackery/ransack/pull/460)).
|
||||
* Add support and tests for passing stringy booleans for ransackable scopes
|
||||
([pull request](https://github.com/activerecord-hackery/ransack/pull/460)).
|
||||
|
||||
*Josh Kovach*
|
||||
|
||||
### Changed
|
||||
|
||||
## Version 1.5.1 - 2014-10-30
|
||||
### Fixed
|
||||
|
||||
* Fix a regression caused by incorrect string constants in `context.rb`.
|
||||
|
||||
*Kazuhiro Nishiyama*
|
||||
|
||||
### Added
|
||||
|
||||
* Add base specs for search on fields with `_start` and `_end`.
|
||||
|
@ -17,20 +28,14 @@ henceforth should be documented here.
|
|||
*Jon Atack*
|
||||
|
||||
* Add a failing spec for detecting attribute fields containing `_and_` that
|
||||
needs to be fixed. Method names containing `_and_` and `_or_` are still not
|
||||
parsed/detected correctly.
|
||||
needs to be fixed. Attribute names containing `_and_` and `_or_` are still
|
||||
not parsed/detected correctly.
|
||||
|
||||
*Jon Atack*
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix a regression caused by incorrect string constants in context.rb.
|
||||
|
||||
*Kazuhiro NISHIYAMA*
|
||||
|
||||
### Changed
|
||||
|
||||
* Remove duplicate code in spec/support/schema.rb.
|
||||
* Remove duplicate code in `spec/support/schema.rb`.
|
||||
|
||||
*Jon Atack*
|
||||
|
||||
|
@ -101,7 +106,6 @@ henceforth should be documented here.
|
|||
|
||||
*Jon Atack*
|
||||
|
||||
|
||||
## Version 1.4.1 - 2014-09-23
|
||||
### Fixed
|
||||
|
||||
|
@ -109,7 +113,6 @@ henceforth should be documented here.
|
|||
|
||||
*Jon Atack*
|
||||
|
||||
|
||||
## Version 1.4.0 - 2014-09-23
|
||||
### Added
|
||||
|
||||
|
|
|
@ -461,7 +461,11 @@ Employee.search({ active: true, hired_since: '2013-01-01' })
|
|||
Employee.search({ salary_gt: 100_000 }, { auth_object: current_user })
|
||||
```
|
||||
|
||||
If the `true` value is being passed via url params or by some other mechanism that will convert it to a string (i.e. `"active" => "true"`), the true value will *not* be passed to the scope. If you want to pass a `'true'` string to the scope, you should wrap it in an array (i.e. `"active" => ['true']`).
|
||||
If the `true` value is being passed via url params or by some other mechanism
|
||||
that will convert it to a string (i.e. `active: 'true'` instead of
|
||||
`active: true`), the true value will *not* be passed to the scope. If you want
|
||||
to pass a `'true'` string to the scope, you should wrap it in an array (i.e.
|
||||
`active: ['true']`).
|
||||
|
||||
Scopes are a recent addition to Ransack and currently have a few caveats:
|
||||
First, a scope involving child associations needs to be defined in the parent
|
||||
|
@ -471,7 +475,7 @@ wrapped in an array to function (see
|
|||
[this issue](https://github.com/activerecord-hackery/ransack/issues/404)),
|
||||
which is not compatible with Ransack form helpers. For this use case, it may be
|
||||
better for now to use [ransackers]
|
||||
(https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers) instead
|
||||
(https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers) instead,
|
||||
where feasible. Pull requests with solutions and tests are welcome!
|
||||
|
||||
### Grouping queries by OR instead of AND
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
require 'action_view'
|
||||
|
||||
# This patch is needed since this Rails commit:
|
||||
# https://github.com/rails/rails/commit/c1a118a
|
||||
#
|
||||
# TODO: Find a better a better to solve this.
|
||||
#
|
||||
module ActionView::Helpers::Tags
|
||||
class Base
|
||||
private
|
||||
def value(object)
|
||||
object.send @method_name if object # use send instead of public_send
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RANSACK_FORM_BUILDER = 'RANSACK_FORM_BUILDER'.freeze
|
||||
|
||||
require 'simple_form' if
|
||||
|
@ -126,9 +140,8 @@ module Ransack
|
|||
end
|
||||
end
|
||||
collection = keys.map { |k| [k, Translate.predicate(k)] }
|
||||
object.predicate ||= Predicate.named(default) if can_use_default?(
|
||||
default, :predicate, keys
|
||||
)
|
||||
object.predicate ||= Predicate.named(default) if
|
||||
can_use_default?(default, :predicate, keys)
|
||||
template_collection_select(:p, collection, options, html_options)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue