meta_search 0.9.11 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/README.rdoc +47 -3
- data/VERSION +1 -1
- data/meta_search.gemspec +2 -2
- data/test/test_view_helpers.rb +1 -13
- metadata +4 -4
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -273,12 +273,12 @@ MetaSearch adds a helper for this:
|
|
273
273
|
lets you sandwich a list of fields, each in hash format, between the attribute and the usual
|
274
274
|
options hash. See MetaSearch::Helpers::FormBuilder for more info.
|
275
275
|
|
276
|
-
===
|
276
|
+
=== checks and collection_checks
|
277
277
|
|
278
278
|
If you need to get an array into your where, and you don't care about parameter order,
|
279
279
|
you might choose to use a select or collection_select with multiple selection enabled,
|
280
280
|
but everyone hates multiple selection boxes. MetaSearch adds a couple of additional
|
281
|
-
helpers, +
|
281
|
+
helpers, +checks+ and +collection_checks+ to handle multiple selections in a
|
282
282
|
more visually appealing manner. They can be called with or without a block. Without a
|
283
283
|
block, you get an array of MetaSearch::Check objects to do with as you please.
|
284
284
|
|
@@ -286,7 +286,7 @@ With a block, each check is yielded to your template, like so:
|
|
286
286
|
|
287
287
|
<h4>How many heads?</h4>
|
288
288
|
<ul>
|
289
|
-
<% f.
|
289
|
+
<% f.checks :number_of_heads_in,
|
290
290
|
[['One', 1], ['Two', 2], ['Three', 3]], :class => 'checkboxy' do |check| %>
|
291
291
|
<li>
|
292
292
|
<%= check.box %>
|
@@ -363,6 +363,50 @@ Excluded attributes on a model will be honored across associations, so if an Art
|
|
363
363
|
Then your call to <tt>Article.search</tt> will allow <tt>:comments_body_contains</tt>
|
364
364
|
but not <tt>:comments_user_id_equals</tt> to be passed.
|
365
365
|
|
366
|
+
=== Conditional access to searches
|
367
|
+
|
368
|
+
<tt>search_methods</tt>, <tt>attr_searchable</tt>, <tt>attr_unsearchable</tt>,
|
369
|
+
<tt>assoc_searchable</tt>, and <tt>assoc_unsearchable</tt> all accept an <tt>:if</tt>
|
370
|
+
option. If present, it should specify a Proc (or other object responding to <tt>call</tt>)
|
371
|
+
that accepts a single parameter. This parameter will be the instance of the MetaSearch::Builder
|
372
|
+
that gets created by a call to Model.search. Any unused search options (the second hash param)
|
373
|
+
that get passed to Model.search will be available via the Builder object's <tt>options</tt>
|
374
|
+
reader, and can be used for access control via this proc/object.
|
375
|
+
|
376
|
+
Example:
|
377
|
+
|
378
|
+
assoc_unsearchable :notes,
|
379
|
+
:if => proc {|s| s.options[:access] == 'blocked' || !s.options[:access]}
|
380
|
+
|
381
|
+
=== Localization
|
382
|
+
|
383
|
+
MetaSearch supports i18n localization in a few different ways. Consider this abbreviated
|
384
|
+
example "flanders" locale:
|
385
|
+
|
386
|
+
flanders:
|
387
|
+
activerecord:
|
388
|
+
attributes:
|
389
|
+
company:
|
390
|
+
name: "Company name-diddly"
|
391
|
+
developer:
|
392
|
+
name: "Developer name-diddly"
|
393
|
+
salary: "Developer salary-doodly"
|
394
|
+
meta_search:
|
395
|
+
or: 'or-diddly'
|
396
|
+
predicates:
|
397
|
+
contains: "%{attribute} contains-diddly"
|
398
|
+
equals: "%{attribute} equals-diddly"
|
399
|
+
attributes:
|
400
|
+
company:
|
401
|
+
reverse_name: "Company reverse name-diddly"
|
402
|
+
developer:
|
403
|
+
name_contains: "Developer name-diddly contains-aroonie"
|
404
|
+
|
405
|
+
First, MetaSearch will use a key found under meta_search.attributes.model_name.attribute_name,
|
406
|
+
if it exists. As a fallback, it will use a localization based on the predicate type, along with
|
407
|
+
the usual ActiveRecord attribute localization (the activerecord.attributes.model_name keys above).
|
408
|
+
Additionally, a localized "or" can be specified for multi-column searches.
|
409
|
+
|
366
410
|
== Contributions
|
367
411
|
|
368
412
|
There are several ways you can help MetaSearch continue to improve.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/meta_search.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{meta_search}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ernie Miller"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-17}
|
13
13
|
s.description = %q{
|
14
14
|
Allows simple search forms to be created against an AR3 model
|
15
15
|
and its associations, has useful view helpers for sort links
|
data/test/test_view_helpers.rb
CHANGED
@@ -17,19 +17,7 @@ class TestViewHelpers < ActionView::TestCase
|
|
17
17
|
include router.url_helpers
|
18
18
|
|
19
19
|
def setup
|
20
|
-
@controller =
|
21
|
-
|
22
|
-
attr_reader :url_for_options
|
23
|
-
def url_for(options)
|
24
|
-
@url_for_options = options
|
25
|
-
"http://www.example.com"
|
26
|
-
end
|
27
|
-
|
28
|
-
def _routes
|
29
|
-
@routes ||= ActionDispatch::Routing::RouteSet.new
|
30
|
-
end
|
31
|
-
end
|
32
|
-
@controller = @controller.new
|
20
|
+
@controller = ActionView::TestCase::TestController.new
|
33
21
|
end
|
34
22
|
|
35
23
|
context "A search against Company and a search against Developer" do
|
metadata
CHANGED
@@ -3,10 +3,10 @@ name: meta_search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
+
- 1
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
|
9
|
-
version: 0.9.11
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ernie Miller
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-17 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|