ransack 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +2 -1
- data/lib/ransack/helpers/form_helper.rb +4 -4
- data/lib/ransack/version.rb +1 -1
- data/spec/ransack/helpers/form_helper_spec.rb +11 -2
- data/spec/support/schema.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc4a8f835fc26d7d315572626021b65eb52c4ed
|
4
|
+
data.tar.gz: 79a2066b2c62fa03718561266d7b9a9219f31b96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e315ac655c3acd20683166b2444d535abeaeeefb525af68740235fff805483ce230d483fe968ace4432141aa47fbb38d413b906dccaeff9c8e50b39e30347567
|
7
|
+
data.tar.gz: a4de93cc2211f753183182645ce5f8c8810af8b60d3687d3b9bccb07e303c63dd50296a9e61ba8b2cce04efa8fe91c2d1b6303551869a2870fe3abed3e2391b3
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## Version 1.6.2 - 2015-01-14
|
4
|
+
|
5
|
+
* Fix a regression
|
6
|
+
([#494](https://github.com/activerecord-hackery/ransack/issues/494))
|
7
|
+
where passing an array of routes of `search_form_for` no longer worked,
|
8
|
+
and add a failing/passing test that would have caught the issue.
|
9
|
+
|
10
|
+
*Daniel Rikowski*, *Jon Atack*
|
11
|
+
|
12
|
+
|
3
13
|
## Version 1.6.1 - 2015-01-14
|
4
14
|
|
5
|
-
* Fix a regression with using `in` predicates caused by PR [#488](https://github.com/activerecord-hackery/ransack/pull/488))
|
15
|
+
* Fix a regression with using `in` predicates caused by PR [#488](https://github.com/activerecord-hackery/ransack/pull/488)) and add a test.
|
6
16
|
|
7
17
|
* README improvements to clarify `sort_link` syntax with associations and
|
8
18
|
Ransack#search vs #ransack.
|
data/README.md
CHANGED
@@ -27,7 +27,8 @@ instead.
|
|
27
27
|
If you're viewing this at
|
28
28
|
[github.com/activerecord-hackery/ransack](https://github.com/activerecord-hackery/ransack),
|
29
29
|
you're reading the documentation for the master branch with the latest features.
|
30
|
-
[View documentation for the last release (1.6.
|
30
|
+
[View documentation for the last release (1.6.2).]
|
31
|
+
(https://github.com/activerecord-hackery/ransack/tree/v1.6.2)
|
31
32
|
|
32
33
|
## Getting started
|
33
34
|
|
@@ -12,15 +12,15 @@ module Ransack
|
|
12
12
|
options[:url] ||= polymorphic_path(
|
13
13
|
search.klass, format: options.delete(:format)
|
14
14
|
)
|
15
|
-
elsif record.is_a?
|
16
|
-
|
15
|
+
elsif record.is_a?(Array) &&
|
16
|
+
(search = record.detect { |o| o.is_a?(Ransack::Search) })
|
17
17
|
options[:url] ||= polymorphic_path(
|
18
|
-
record.map { |o| o.is_a?
|
18
|
+
record.map { |o| o.is_a?(Ransack::Search) ? o.klass : o },
|
19
19
|
format: options.delete(:format)
|
20
20
|
)
|
21
21
|
else
|
22
22
|
raise ArgumentError,
|
23
|
-
|
23
|
+
'No Ransack::Search object was provided to search_form_for!'
|
24
24
|
end
|
25
25
|
options[:html] ||= {}
|
26
26
|
html_options = {
|
data/lib/ransack/version.rb
CHANGED
@@ -6,8 +6,10 @@ module Ransack
|
|
6
6
|
|
7
7
|
router = ActionDispatch::Routing::RouteSet.new
|
8
8
|
router.draw do
|
9
|
-
resources :people
|
10
|
-
|
9
|
+
resources :people, :notes
|
10
|
+
namespace :admin do
|
11
|
+
resources :comments
|
12
|
+
end
|
11
13
|
get ':controller(/:action(/:id(.:format)))'
|
12
14
|
end
|
13
15
|
|
@@ -372,6 +374,13 @@ module Ransack
|
|
372
374
|
it { should match /action="\/people.json"/ }
|
373
375
|
end
|
374
376
|
|
377
|
+
describe '#search_form_for with an array of routes' do
|
378
|
+
subject {
|
379
|
+
@controller.view_context.search_form_for([:admin, Comment.search]) {}
|
380
|
+
}
|
381
|
+
it { should match /action="\/admin\/comments"/ }
|
382
|
+
end
|
383
|
+
|
375
384
|
describe '#search_form_for with custom default search key' do
|
376
385
|
before do
|
377
386
|
Ransack.configure { |c| c.search_key = :example }
|
data/spec/support/schema.rb
CHANGED
@@ -39,17 +39,21 @@ class Person < ActiveRecord::Base
|
|
39
39
|
scope :restricted, lambda { where("restricted = 1") }
|
40
40
|
scope :active, lambda { where("active = 1") }
|
41
41
|
scope :over_age, lambda { |y| where(["age > ?", y]) }
|
42
|
-
scope :of_age, lambda { |of_age|
|
42
|
+
scope :of_age, lambda { |of_age|
|
43
|
+
of_age ? where("age >= ?", 18) : where("age < ?", 18)
|
44
|
+
}
|
43
45
|
|
44
46
|
ransacker :reversed_name, :formatter => proc { |v| v.reverse } do |parent|
|
45
47
|
parent.table[:name]
|
46
48
|
end
|
47
49
|
|
48
|
-
ransacker :array_users,
|
50
|
+
ransacker :array_users,
|
51
|
+
formatter: proc { |v| Person.first(2).map(&:id) } do |parent|
|
49
52
|
parent.table[:id]
|
50
53
|
end
|
51
54
|
|
52
|
-
ransacker :array_names,
|
55
|
+
ransacker :array_names,
|
56
|
+
formatter: proc { |v| Person.first(2).map { |p| p.id.to_s } } do |parent|
|
53
57
|
parent.table[:name]
|
54
58
|
end
|
55
59
|
|