alphabetical_paginate 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,10 +4,10 @@ module AlphabeticalPaginate
4
4
  base.extend(self)
5
5
  end
6
6
 
7
- def alpha_paginate current_field, params = {enumerate:false, default_field: "a",
7
+ def alpha_paginate current_field, params = {enumerate:false, default_field: "a",
8
8
  paginate_all: false, numbers: true,
9
9
  others: true, pagination_class: "pagination-centered",
10
- batch_size: 500, db_mode: false,
10
+ batch_size: 500, db_mode: false,
11
11
  db_field: "id", include_all: true,
12
12
  js: true, support_language: :en,
13
13
  bootstrap3: false, slugged_link: false,
@@ -29,7 +29,7 @@ module AlphabeticalPaginate
29
29
  params[:all_as_link] = true if !params.has_key? :all_as_link
30
30
 
31
31
  output = []
32
-
32
+
33
33
  if params[:db_mode]
34
34
  letters = nil
35
35
  if !params[:paginate_all]
@@ -56,11 +56,11 @@ module AlphabeticalPaginate
56
56
  if all
57
57
  output = self
58
58
  else
59
-
59
+
60
60
  # In this case we can speed up the search taking advantage of the indices
61
61
  can_go_quicker = (current_field =~ params[:language].letters_regexp) || (current_field =~ /[0-9]/ && params[:enumerate])
62
62
 
63
-
63
+
64
64
  # Use LIKE the most as you can to take advantage of indeces on the field when available
65
65
  # REGEXP runs always a full scan of the table!
66
66
  # For more information about LIKE and indeces have a look at
@@ -91,7 +91,7 @@ module AlphabeticalPaginate
91
91
  when /[0-9]/
92
92
  if params[:enumerate]
93
93
  availableLetters[field_letter] = true if !availableLetters.has_key? field_letter
94
- output << x if all || (current_field =~ /[0-9]/ && field_letter == current_field)
94
+ output << x if all || (current_field =~ /[0-9]/ && field_letter == current_field)
95
95
  else
96
96
  availableLetters['0-9'] = true if !availableLetters.has_key? 'numbers'
97
97
  output << x if all || current_field == "0-9"
@@ -134,7 +134,8 @@ module AlphabeticalPaginate
134
134
 
135
135
  def find_available_letters(db_field)
136
136
  # safe the field (look for the ActiveRecord valid attributes)
137
- if db_field.nil? || !self.attribute_names.include?(db_field)
137
+ # but allow explict table name prefixes in order to avoid 'field list is ambiguous' errors
138
+ if db_field.nil? || !self.attribute_names.include?(db_field.to_s.split('.').last)
138
139
  db_field = 'id'
139
140
  end
140
141
  criteria = "substr( %s, 1 , 1)" % db_field
@@ -1,3 +1,3 @@
1
1
  module AlphabeticalPaginate
2
- VERSION = "2.3.1"
2
+ VERSION = "2.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphabetical_paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
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: 2015-05-19 00:00:00.000000000 Z
12
+ date: 2016-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler