active_scaffold-sequel 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  module ActiveScaffold::Actions
2
2
  module Search
3
3
  include ActiveScaffold::Actions::CommonSearch
4
+
4
5
  def self.included(base)
5
6
  base.before_filter :search_authorized_filter, :only => :show_search
6
7
  base.before_filter :store_search_params_into_session, :only => [:index]
@@ -13,14 +14,17 @@ module ActiveScaffold::Actions
13
14
  end
14
15
 
15
16
  protected
17
+
16
18
  def search_respond_to_html
17
19
  render(:action => "search")
18
20
  end
21
+
19
22
  def search_respond_to_js
20
23
  render(:partial => "search")
21
24
  end
25
+
22
26
  def do_search
23
- query = search_params.to_s.strip rescue ''
27
+ query = search_params.to_s
24
28
  unless query.empty?
25
29
  columns = active_scaffold_config.search.columns
26
30
  text_search = active_scaffold_config.search.text_search
@@ -37,10 +41,12 @@ module ActiveScaffold::Actions
37
41
  end
38
42
 
39
43
  private
44
+
40
45
  def search_authorized_filter
41
46
  link = active_scaffold_config.search.link || active_scaffold_config.search.class.link
42
47
  raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
43
48
  end
49
+
44
50
  def search_formats
45
51
  (default_formats + active_scaffold_config.formats + active_scaffold_config.search.formats).uniq
46
52
  end
@@ -9,9 +9,13 @@ module ActiveScaffold
9
9
  return unless columns.length > 0
10
10
  like_pattern = like_pattern(text_search)
11
11
  tokens = [tokens] if tokens.is_a? String
12
- obj = active_scaffold_config.model.new # for typecasting purposes
13
12
 
14
- tokens.collect do |token|
13
+ # for typecasting purposes
14
+ obj = active_scaffold_config.model.new
15
+ orig_raise_on_typecast_failure = active_scaffold_config.model.raise_on_typecast_failure
16
+ active_scaffold_config.model.raise_on_typecast_failure = true
17
+
18
+ result = tokens.collect do |token|
15
19
  pattern = like_pattern.sub('?', token)
16
20
  columns.collect do |column|
17
21
  if column.column.nil? or column.column[:type] == :string
@@ -24,6 +28,11 @@ module ActiveScaffold
24
28
  end
25
29
  end.compact.inject {|a,b| (a | b)}
26
30
  end.inject {|a,b| (a & b)}
31
+
32
+ # restore original setting
33
+ active_scaffold_config.model.raise_on_typecast_failure = orig_raise_on_typecast_failure
34
+
35
+ result
27
36
  end
28
37
 
29
38
  # Generates an SQL condition for the given ActiveScaffold column based on
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 6
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-08 00:00:00.000000000 Z
12
+ date: 2013-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda