ransack 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -4
  3. data/CONTRIBUTING.md +12 -4
  4. data/Gemfile +4 -5
  5. data/README.md +160 -55
  6. data/lib/ransack.rb +1 -1
  7. data/lib/ransack/adapters/active_record/3.0/context.rb +16 -0
  8. data/lib/ransack/adapters/active_record/3.1/context.rb +24 -0
  9. data/lib/ransack/adapters/active_record/base.rb +6 -0
  10. data/lib/ransack/adapters/active_record/context.rb +49 -1
  11. data/lib/ransack/configuration.rb +23 -6
  12. data/lib/ransack/constants.rb +46 -45
  13. data/lib/ransack/context.rb +19 -2
  14. data/lib/ransack/helpers/form_builder.rb +5 -4
  15. data/lib/ransack/helpers/form_helper.rb +34 -14
  16. data/lib/ransack/locale/hu.yml +70 -0
  17. data/lib/ransack/locale/nl.yml +70 -0
  18. data/lib/ransack/nodes/attribute.rb +2 -2
  19. data/lib/ransack/nodes/condition.rb +29 -12
  20. data/lib/ransack/nodes/grouping.rb +6 -6
  21. data/lib/ransack/nodes/node.rb +1 -1
  22. data/lib/ransack/nodes/value.rb +1 -1
  23. data/lib/ransack/predicate.rb +4 -5
  24. data/lib/ransack/ransacker.rb +1 -1
  25. data/lib/ransack/search.rb +39 -13
  26. data/lib/ransack/translate.rb +7 -8
  27. data/lib/ransack/version.rb +1 -1
  28. data/ransack.gemspec +5 -5
  29. data/spec/ransack/adapters/active_record/base_spec.rb +78 -35
  30. data/spec/ransack/adapters/active_record/context_spec.rb +58 -15
  31. data/spec/ransack/configuration_spec.rb +18 -18
  32. data/spec/ransack/dependencies_spec.rb +1 -1
  33. data/spec/ransack/helpers/form_builder_spec.rb +29 -29
  34. data/spec/ransack/helpers/form_helper_spec.rb +14 -1
  35. data/spec/ransack/nodes/condition_spec.rb +21 -2
  36. data/spec/ransack/predicate_spec.rb +49 -9
  37. data/spec/ransack/search_spec.rb +178 -143
  38. data/spec/ransack/translate_spec.rb +1 -1
  39. data/spec/spec_helper.rb +1 -0
  40. data/spec/support/schema.rb +26 -21
  41. metadata +15 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aa40c542dc092988fc46513f6f30ea6ccef3ca6
4
- data.tar.gz: 22a6a9efcafac2879f41cbaa5f90fdac6d9d85f8
3
+ metadata.gz: ce6d8c3f3a255efe1c665afc046f8b03c5ff907f
4
+ data.tar.gz: cca91cd37e10bbcf3c69df6553a4b09cdfc606d8
5
5
  SHA512:
6
- metadata.gz: f31218e27e2a9aae5cd2bbaf5588627872338c4f5fcb6babb8f2dc4b81abf0c645ea3edb84ee514aaa2d946621c54cbba835400b9389ad8f61bd68356e6c2890
7
- data.tar.gz: 117c2bf5a8f01b1461a03073c335dcb544ccf6b09187517123c90235efac7465cf4c9bde21d6f3e75880e3a032b0bc9b4e04a9c006cb7a15111fbadfd6486ed7
6
+ metadata.gz: f7d39c9fa75f48bcf996e04050b188f1f3c5e47c1ee5f8edd85deb4fdd6193da986d88230b781f8095559db691e1f8ba7d73034107565a3eecc35bf259b509bf
7
+ data.tar.gz: 3a0a64c7295ccc4fe744a568db56ad24dea62e52f325e9edf750cb729b08ec33f1fcd47bd4dce6d6ee1f53cd0a9639bbd7952dc175908b5b1dc76ee504c317ef
@@ -1,12 +1,11 @@
1
1
  language: ruby
2
2
 
3
- before_install:
4
- - travis_retry gem install bundler
3
+ sudo: false
5
4
 
6
5
  rvm:
6
+ - 2.1
7
+ - 2.0
7
8
  - 1.9.3
8
- - 2.0.0
9
- - 2.1.1
10
9
 
11
10
  env:
12
11
  - RAILS=4-1-stable DB=sqlite3
@@ -5,8 +5,8 @@ Ransack is an open source project and we encourage contributions.
5
5
  When filing an issue on the Ransack project, please provide these details:
6
6
 
7
7
  * A comprehensive list of steps to reproduce the issue.
8
- * The version of Ransack *and* the version of Rails.
9
- * Any relevant stack traces ("Full trace" preferred)
8
+ * The version of Ransack *and* the version of Rails and Ruby.
9
+ * Any relevant stack traces ("Full trace" preferred).
10
10
 
11
11
  In 99% of cases, this information is enough to determine the cause and
12
12
  solution to the problem that is being described.
@@ -20,6 +20,10 @@ if the information requested is provided.
20
20
  We gladly accept pull requests to fix bugs and, in some circumstances, add new
21
21
  features to Ransack.
22
22
 
23
+ Before issuing a pull request, please make sure that all specs are passing,
24
+ that any new features have test coverage, and that anything that breaks
25
+ backward compatibility has a very good reason for doing so.
26
+
23
27
  Here's a quick guide:
24
28
 
25
29
  1. Fork the repo.
@@ -38,7 +42,9 @@ a test!
38
42
 
39
43
  5. Push to your fork and submit a pull request. If the changes will apply
40
44
  cleanly to the latest stable branches and master branch, you will only need
41
- to submit one pull request.
45
+ to submit one pull request. If the pull request only contains documentation
46
+ changes, please add `[skip ci]` to the commit message so that the Travis test
47
+ suite does not needlessly run.
42
48
 
43
49
  At this point you're waiting on us. We like to at least comment on, if not
44
50
  accept, pull requests within three business days (and, typically, one business
@@ -55,11 +61,13 @@ taken straight from the Ruby on Rails guide:
55
61
  Syntax:
56
62
 
57
63
  * Two spaces, no tabs.
64
+ * 80 characters per line.
58
65
  * No trailing whitespace. Blank lines should not have any space.
59
66
  * Prefer &&/|| over and/or.
60
67
  * `MyClass.my_method(my_arg)` not `my_method( my_arg )` or my_method my_arg.
61
68
  * `a = b` and not `a=b`.
62
- * `a_method { |block| ... }` and not `a_method { | block | ... }`
69
+ * `a_method { |block| ... }` and not `a_method { | block | ... }` or
70
+ `a_method{|block| ...}`.
63
71
  * Follow the conventions you see used in the source already.
64
72
 
65
73
  And in case we didn't emphasize it enough: we love tests!
data/Gemfile CHANGED
@@ -5,23 +5,22 @@ gem 'rake'
5
5
 
6
6
  rails = ENV['RAILS'] || '4-1-stable'
7
7
 
8
- gem 'polyamorous', '~> 1.0.0'
8
+ gem 'polyamorous', '~> 1.1'
9
9
 
10
10
  case rails
11
11
  when /\// # A path
12
12
  gem 'activesupport', path: "#{rails}/activesupport"
13
- gem 'activemodel', path: "#{rails}/activemodel"
14
13
  gem 'activerecord', path: "#{rails}/activerecord"
15
- gem 'actionpack', path: "#{rails}/activerecord"
14
+ gem 'actionpack', path: "#{rails}/actionpack"
16
15
  when /^v/ # A tagged version
17
- git 'git://github.com/rails/rails.git', tag: rails do
16
+ git 'git://github.com/rails/rails.git', :tag => rails do
18
17
  gem 'activesupport'
19
18
  gem 'activemodel'
20
19
  gem 'activerecord'
21
20
  gem 'actionpack'
22
21
  end
23
22
  else
24
- git 'git://github.com/rails/rails.git', branch: rails do
23
+ git 'git://github.com/rails/rails.git', :branch => rails do
25
24
  gem 'activesupport'
26
25
  gem 'activemodel'
27
26
  gem 'activerecord'
data/README.md CHANGED
@@ -12,7 +12,7 @@ and maintained by [Ryan Bigg](http://twitter.com/ryanbigg),
12
12
  [Jon Atack](http://twitter.com/jonatack) and a great group of [contributors](https://github.com/activerecord-hackery/ransack/graphs/contributors).
13
13
  While it supports many of the same features as MetaSearch, its underlying
14
14
  implementation differs greatly from MetaSearch,
15
- and _backwards compatibility is not a design goal._
15
+ and backwards compatibility is not a design goal.
16
16
 
17
17
  Ransack enables the creation of both simple and
18
18
  [advanced](http://ransack-demo.herokuapp.com/users/advanced_search)
@@ -25,28 +25,43 @@ instead.
25
25
 
26
26
  ## Getting started
27
27
 
28
- In your Gemfile:
28
+ Because ActiveRecord has been evolving quite a bit, your friendly Ransack is
29
+ available in several flavors! Take your pick:
30
+
31
+ In your Gemfile, for the last officially released gem compatible with Rails
32
+ 3.x, 4.0 and 4.1 (for Rails 4.2, use the dedicated `rails-4.2` branch described
33
+ below for now):
34
+
35
+ ```ruby
36
+ gem 'ransack'
37
+ ```
38
+
39
+ Or if you want to use the latest updates on the Ransack master branch:
29
40
 
30
41
  ```ruby
31
- gem "ransack" # Last officially released gem (compatible with Rails 3, 4.0 and 4.1!)
42
+ gem 'ransack', github: 'activerecord-hackery/ransack'
32
43
  ```
33
44
 
34
- Or if you want to use the latest updates on the master branch:
45
+ If you are using Rails 4.1, you may prefer the dedicated [Rails 4.1 branch](https://github.com/activerecord-hackery/ransack/tree/rails-4.1) which
46
+ contains the latest updates, supports only 4.1, and is lighter and somewhat
47
+ faster:
35
48
 
36
49
  ```ruby
37
- gem "ransack", github: "activerecord-hackery/ransack" # Track git repo
50
+ gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails-4.1'
38
51
  ```
39
52
 
40
- If you are on Rails 4.1 (or 4.2.0.alpha or master), you may prefer to use the dedicated [Rails 4.1 branch](https://github.com/activerecord-hackery/ransack/tree/rails-4.1) which contains the latest updates, supports only 4.1 and up, and is lighter and somewhat faster:
53
+ Similarly, if you are using Rails 4.0, you may prefer the dedicated [Rails 4 branch](https://github.com/activerecord-hackery/ransack/tree/rails-4) for the
54
+ same reasons:
41
55
 
42
56
  ```ruby
43
- gem "ransack", github: "activerecord-hackery/ransack", branch: "rails-4.1"
57
+ gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails-4'
44
58
  ```
45
59
 
46
- Similarly, if you are on Rails 4.0, you may prefer to use the dedicated [Rails 4 branch](https://github.com/activerecord-hackery/ransack/tree/rails-4) for the same reasons:
60
+ Last but definitely not least, an experimental [Rails 4.2 branch](https://github.com/activerecord-hackery/ransack/tree/rails-4.2) is
61
+ available for those on the edge:
47
62
 
48
63
  ```ruby
49
- gem "ransack", github: "activerecord-hackery/ransack", branch: "rails-4"
64
+ gem 'ransack', github: 'activerecord-hackery/ransack', branch: 'rails-4.2'
50
65
  ```
51
66
 
52
67
  ## Usage
@@ -55,33 +70,35 @@ Ransack can be used in one of two modes, simple or advanced.
55
70
 
56
71
  ### Simple Mode
57
72
 
58
- This mode works much like MetaSearch, for those of you who are familiar with it, and
59
- requires very little setup effort.
73
+ This mode works much like MetaSearch, for those of you who are familiar with
74
+ it, and requires very little setup effort.
60
75
 
61
76
  If you're coming from MetaSearch, things to note:
62
77
 
63
- 1. The default param key for search params is now `:q`, instead of `:search`. This is
64
- primarily to shorten query strings, though advanced queries (below) will still
65
- run afoul of URL length limits in most browsers and require a switch to HTTP
66
- POST requests. This key is
67
- [configurable](https://github.com/activerecord-hackery/ransack/wiki/Configuration).
78
+ 1. The default param key for search params is now `:q`, instead of `:search`.
79
+ This is primarily to shorten query strings, though advanced queries (below)
80
+ will still run afoul of URL length limits in most browsers and require a
81
+ switch to HTTP POST requests. This key is [configurable]
82
+ (https://github.com/activerecord-hackery/ransack/wiki/Configuration).
68
83
 
69
- 2. `form_for` is now `search_form_for`, and validates that a Ransack::Search object
70
- is passed to it.
84
+ 2. `form_for` is now `search_form_for`, and validates that a Ransack::Search
85
+ object is passed to it.
71
86
 
72
- 3. Common ActiveRecord::Relation methods are no longer delegated by the search object.
73
- Instead, you will get your search results (an ActiveRecord::Relation in the case of
74
- the ActiveRecord adapter) via a call to `Search#result`. If passed `distinct: true`,
75
- `result` will generate a `SELECT DISTINCT` to avoid returning duplicate rows, even if
76
- conditions on a join would otherwise result in some.
87
+ 3. Common ActiveRecord::Relation methods are no longer delegated by the
88
+ search object. Instead, you will get your search results (an
89
+ ActiveRecord::Relation in the case of the ActiveRecord adapter) via a call to
90
+ `Search#result`. If passed `distinct: true`, `result` will generate a `SELECT
91
+ DISTINCT` to avoid returning duplicate rows, even if conditions on a join
92
+ would otherwise result in some.
77
93
 
78
- Please note that for many databases, a sort on an associated table's columns will
79
- result in invalid SQL with `distinct: true` -- in those cases, you're on your own,
80
- and will need to modify the result as needed to allow these queries to work. Thankfully,
81
- 9 times out of 10, sort against the search's base is sufficient, though, as that's
82
- generally what's being displayed on your results page.
94
+ Please note that for many databases, a sort on an associated table's columns
95
+ will result in invalid SQL with `distinct: true` -- in those cases, you're on
96
+ your own, and will need to modify the result as needed to allow these queries
97
+ to work. Thankfully, 9 times out of 10, sort against the search's base is
98
+ sufficient, though, as that's generally what's being displayed on your
99
+ results page.
83
100
 
84
- In your controller:
101
+ ####In your controller
85
102
 
86
103
  ```ruby
87
104
  def index
@@ -89,40 +106,68 @@ def index
89
106
  @people = @q.result(distinct: true)
90
107
  end
91
108
  ```
109
+ or without `distinct:true`, for sorting on an associated table's columns (in
110
+ this example, with preloading each Person's Articles and pagination):
92
111
 
93
- In your view:
112
+ ```ruby
113
+ def index
114
+ @q = Person.search(params[:q])
115
+ @people = @q.result.includes(:articles).page(params[:page])
116
+ end
117
+ ```
118
+
119
+ ####In your view
120
+
121
+ The two primary Ransack view helpers are `search_form_for` and `sort_link`,
122
+ which are defined in
123
+ [Ransack::Helpers::FormHelper](lib/ransack/helpers/form_helper.rb).
124
+
125
+ #####1. Ransack's `search_form_for` helper replaces `form_for` for creating the view search form:
94
126
 
95
127
  ```erb
96
128
  <%= search_form_for @q do |f| %>
97
129
  <%= f.label :name_cont %>
98
- <%= f.text_field :name_cont %>
130
+ <%= f.search_field :name_cont %>
99
131
  <%= f.label :articles_title_start %>
100
- <%= f.text_field :articles_title_start %>
132
+ <%= f.search_field :articles_title_start %>
101
133
  <%= f.submit %>
102
134
  <% end %>
103
135
  ```
104
136
 
105
- `cont` (contains) and `start` (starts with) are just two of the available search predicates.
106
- See [Constants](https://github.com/activerecord-hackery/ransack/blob/master/lib/ransack/constants.rb) for a full list and the [wiki](https://github.com/activerecord-hackery/ransack/wiki/Basic-Searching) for more description.
137
+ `cont` (contains) and `start` (starts with) are just two of the available
138
+ search predicates. See [Constants]
139
+ (https://github.com/activerecord-hackery/ransack/blob/master/lib/ransack/constants.rb)
140
+ for a full list and the [wiki]
141
+ (https://github.com/activerecord-hackery/ransack/wiki/Basic-Searching)
142
+ for more information.
107
143
 
108
- You can also set the `search_form_for` answer format, like this:
144
+ The `search_form_for` answer format can be set like this:
109
145
  ```erb
110
146
  <%= search_form_for(@q, format: :pdf) do |f| %>
111
- ...
112
- <% end %>
113
147
 
114
148
  <%= search_form_for(@q, format: :json) do |f| %>
115
- ...
116
- <% end %>
149
+ ```
150
+
151
+ #####2. Ransack's `sort_link` helper creates table headers that are sortable links:
152
+
153
+ ```erb
154
+ <%= content_tag :th, sort_link(@q, :name) %>
155
+ ```
156
+ Additional options can be passed after the column attribute, like a different
157
+ column title or a default sort order:
158
+
159
+ ```erb
160
+ <%= content_tag :th, sort_link(@q, :name, 'Last Name', default_order: :desc) %>
117
161
  ```
118
162
 
119
163
  ### Advanced Mode
120
164
 
121
- "Advanced" searches (ab)use Rails' nested attributes functionality in order to generate
122
- complex queries with nested AND/OR groupings, etc. This takes a bit more work but can
123
- generate some pretty cool search interfaces that put a lot of power in the hands of
124
- your users. A notable drawback with these searches is that the increased size of the
125
- parameter string will typically force you to use the HTTP POST method instead of GET. :(
165
+ "Advanced" searches (ab)use Rails' nested attributes functionality in order to
166
+ generate complex queries with nested AND/OR groupings, etc. This takes a bit
167
+ more work but can generate some pretty cool search interfaces that put a lot of
168
+ power in the hands of your users. A notable drawback with these searches is
169
+ that the increased size of the parameter string will typically force you to use
170
+ the HTTP POST method instead of GET. :(
126
171
 
127
172
  This means you'll need to tweak your routes...
128
173
 
@@ -156,7 +201,9 @@ construct much more complex search forms, such as the one on the
156
201
 
157
202
  ### Ransack #search method
158
203
 
159
- 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:
204
+ Ransack will try to to make `#search` available in your models, but in the case
205
+ that `#search` has already been defined, you can use `#ransack` instead. For
206
+ example the following would be equivalent:
160
207
 
161
208
  ```ruby
162
209
  Article.search(params[:q])
@@ -196,7 +243,7 @@ end
196
243
  class SupervisorsController < ApplicationController
197
244
  def index
198
245
  @search = Supervisor.search(params[:q])
199
- @supervisors = @search.result(distinct: true)
246
+ @supervisors = @search.result.includes(:department, :employees)
200
247
  end
201
248
  end
202
249
  ```
@@ -206,21 +253,40 @@ end
206
253
  ```erb
207
254
  <%= search_form_for @search do |f| %>
208
255
  <%= f.label :last_name_cont %>
209
- <%= f.text_field :last_name_cont %>
256
+ <%= f.search_field :last_name_cont %>
210
257
 
211
258
  <%= f.label :department_title_cont %>
212
- <%= f.text_field :department_title_cont %>
259
+ <%= f.search_field :department_title_cont %>
213
260
 
214
261
  <%= f.label :employees_last_name_cont %>
215
- <%= f.text_field :employees_last_name_cont %>
262
+ <%= f.search_field :employees_last_name_cont %>
216
263
 
217
264
  <%= f.submit "search" %>
218
265
  <% end %>
266
+ ...
267
+ <%= content_tag :table %>
268
+ <%= content_tag :th, sort_link(@q, :last_name) %>
269
+ <%= content_tag :th, sort_link(@q, 'departments.title') %>
270
+ <%= content_tag :th, sort_link(@q, 'employees.last_name') %>
271
+ <% end %>
219
272
  ```
220
273
 
221
- ## Using SimpleForm
274
+ ### Using Ransackers to add custom search functions via Arel
275
+
276
+ The main premise behind Ransack is to provide access to
277
+ **Arel predicate methods**. Ransack provides special methods, called
278
+ _ransackers_, for creating additional search functions via Arel. More
279
+ information about `ransacker` methods can be found [here in the wiki]
280
+ (https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers).
281
+ Feel free to contribute working `ransacker` code examples to the wiki!
282
+
283
+ ### Using SimpleForm
284
+
285
+ If you want to combine form builders of ransack and SimpleForm, just set the
286
+ RANSACK_FORM_BUILDER environment variable before Rails started, e.g. in
287
+ ``config/application.rb`` before ``require 'rails/all'`` and of course use
288
+ ``gem 'simple_form'`` in your ``Gemfile``:
222
289
 
223
- If you want to combine form builders of ransack and SimpleForm, just set the RANSACK_FORM_BUILDER environment variable before Rails started, e.g. in ``config/application.rb`` before ``require 'rails/all'`` and of course use ``gem 'simple_form'`` in your ``Gemfile``:
224
290
  ```ruby
225
291
  require File.expand_path('../boot', __FILE__)
226
292
 
@@ -229,16 +295,55 @@ ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder'
229
295
  require 'rails/all'
230
296
  ```
231
297
 
232
- ## I18n
298
+ ### Authorization
299
+
300
+ By default, Ransack exposes search on any model column, so make sure you
301
+ sanitize your params and only pass the allowed keys. Alternately, you can
302
+ define these class methods on your models to apply selective authorization
303
+ based on a given auth object:
304
+
305
+ * `def self.ransackable_attributes(auth_object = nil)`
306
+ * `def self.ransackable_associations(auth_object = nil)`
307
+ * `def self.ransackable_scopes(auth_object = nil)`
308
+ * `def self.ransortable_attributes(auth_object = nil)` (for sorting)
309
+
310
+ Any values not included in the arrays returned from these methods will be
311
+ ignored. The auth object should be optional when building the search, and is
312
+ ignored by default:
313
+
314
+ ```
315
+ Employee.search({ salary_gt: 100000 }, { auth_object: current_user })
316
+ ```
317
+
318
+ ### Scopes
319
+
320
+ Searching by scope requires defining a whitelist of `ransackable_scopes` on the
321
+ model class. By default all class methods (e.g. scopes) are ignored. Scopes
322
+ will be applied for matching `true` values, or for given values if the scope
323
+ accepts a value:
324
+
325
+ ```
326
+ Employee.search({ active: true, hired_since: '2013-01-01' })
327
+ ```
328
+
329
+ ### I18n
233
330
 
234
- Ransack translation files are available in [Ransack::Locale](lib/ransack/locale). You may also be interested in one of the many translations for Ransack available at http://www.localeapp.com/projects/2999.
331
+ Ransack translation files are available in
332
+ [Ransack::Locale](lib/ransack/locale). You may also be interested in one of the
333
+ many translations for Ransack available at
334
+ http://www.localeapp.com/projects/2999.
235
335
 
236
336
  ## Contributions
237
337
 
238
338
  To support the project:
239
339
 
240
- * Use Ransack in your apps, and let us know if you encounter anything that's broken or missing. A failing spec is awesome. A pull request with tests that pass is even better! Before filing an issue or pull request, be sure to read the [Contributing Guide](CONTRIBUTING.md).
241
- * Spread the word on Twitter, Facebook, and elsewhere if Ransack's been useful to you. The more people who are using the project, the quicker we can find and fix bugs!
340
+ * Use Ransack in your apps, and let us know if you encounter anything that's
341
+ broken or missing. A failing spec is awesome. A pull request with tests that
342
+ pass is even better! Before filing an issue or pull request, be sure to read
343
+ the [Contributing Guide](CONTRIBUTING.md).
344
+ * Spread the word on Twitter, Facebook, and elsewhere if Ransack's been useful
345
+ to you. The more people who are using the project, the quicker we can find and
346
+ fix bugs!
242
347
 
243
348
  ## Copyright
244
349
 
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  Ransack.configure do |config|
12
12
  Ransack::Constants::AREL_PREDICATES.each do |name|
13
- config.add_predicate name, arel_predicate: name
13
+ config.add_predicate name, :arel_predicate => name
14
14
  end
15
15
 
16
16
  Ransack::Constants::DERIVED_PREDICATES.each do |args|
@@ -68,6 +68,22 @@ module Ransack
68
68
  .type
69
69
  end
70
70
 
71
+ # All dependent JoinAssociation items used in the search query
72
+ #
73
+ def join_associations
74
+ @join_dependency.join_associations
75
+ end
76
+
77
+ def join_sources
78
+ raise NotImplementedError,
79
+ "ActiveRecord 3.0 does not use join_sources or support joining relations with Arel::Join nodes. Use join_associations."
80
+ end
81
+
82
+ def alias_tracker
83
+ raise NotImplementedError,
84
+ "ActiveRecord 3.0 does not have an alias tracker"
85
+ end
86
+
71
87
  private
72
88
 
73
89
  def get_parent_and_attribute_name(str, parent = @base)