ballot_box 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ballot_box/base.rb +3 -2
- data/lib/ballot_box/version.rb +1 -1
- data/lib/ballot_box/voting.rb +4 -4
- metadata +4 -4
data/lib/ballot_box/base.rb
CHANGED
@@ -88,12 +88,13 @@ module BallotBox
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def ballot_box_place_scope
|
91
|
-
unscoped.order("#{ballot_box_cached_column} DESC")
|
91
|
+
unscoped.order("#{quoted_table_name}.#{ballot_box_cached_column} DESC")
|
92
92
|
end
|
93
93
|
|
94
|
-
def ballot_box_update_place!
|
94
|
+
def ballot_box_update_place!(scope = nil)
|
95
95
|
table = quoted_table_name
|
96
96
|
subquery = ballot_box_place_scope.select("@row := @row + 1 AS row, #{table}.id").from("#{table}, (SELECT @row := 0) r")
|
97
|
+
subquery = subquery.where(scope) if scope
|
97
98
|
|
98
99
|
query = %(UPDATE #{table} AS a
|
99
100
|
INNER JOIN (
|
data/lib/ballot_box/version.rb
CHANGED
data/lib/ballot_box/voting.rb
CHANGED
@@ -21,7 +21,7 @@ module BallotBox
|
|
21
21
|
validates_numericality_of :value, :only_integer => true
|
22
22
|
|
23
23
|
# Callbacks
|
24
|
-
|
24
|
+
before_create :parse_browser
|
25
25
|
after_save :update_cached_columns
|
26
26
|
after_destroy :update_cached_columns
|
27
27
|
|
@@ -117,9 +117,9 @@ module BallotBox
|
|
117
117
|
protected
|
118
118
|
|
119
119
|
def parse_browser
|
120
|
-
self.browser_name
|
121
|
-
self.browser_version
|
122
|
-
self.browser_platform
|
120
|
+
self.browser_name ||= browser.id.to_s
|
121
|
+
self.browser_version ||= browser.version
|
122
|
+
self.browser_platform ||= browser.platform.to_s
|
123
123
|
end
|
124
124
|
|
125
125
|
def update_cached_columns
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ballot_box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Igor Galeta
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-10-07 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|