go-on-rails 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/generators/gor/templates/gor_model.go.erb +10 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a24ab99957a404da499992b20120d30c163c5925
|
4
|
+
data.tar.gz: 5009bffa97b30a0bef1209ab1b1b12bd5ec727fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 411466805ddf6f18e0797127a25cb30a9458bf5d3143b5fa3a8de2dadafd6ceeb6d385968ed96be02804ca311b73912dca0da3e1f02a329fa8548e272e47dcd6
|
7
|
+
data.tar.gz: 40ddc1ef5a221c2141820ded808ec501e8064df288c92dec7c45ee75b385e91811ed2e2e04409d745144c570ccbd57e8c7a112ef6b6c7e0e849aa117908b4f6a
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Here's a simple [example(tutorial)](https://github.com/goonr/example_simple) sho
|
|
23
23
|
Add this line to your application's Gemfile:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
gem 'go-on-rails', '~> 0.1.
|
26
|
+
gem 'go-on-rails', '~> 0.1.6'
|
27
27
|
```
|
28
28
|
|
29
29
|
And then execute:
|
@@ -101,6 +101,7 @@ And the gem is still under development, so there're a lot of known issues.
|
|
101
101
|
- [x] format(string only)
|
102
102
|
- [x] numericality(partially)
|
103
103
|
- [ ] other validations
|
104
|
+
- [x] Pagination(details see [wiki](https://github.com/goonr/go-on-rails/wiki/Pagination))
|
104
105
|
- [ ] Callbacks
|
105
106
|
- [ ] Transactions
|
106
107
|
|
@@ -155,34 +155,37 @@ func (_p *<%= @model_name %>Page) buildIdRestrict(direction string) (idStr strin
|
|
155
155
|
case "previous":
|
156
156
|
if strings.ToLower(_p.Order["id"]) == "desc" {
|
157
157
|
idStr += "id > ? "
|
158
|
-
idParams = append(
|
158
|
+
idParams = append(idParams, _p.FirstId)
|
159
159
|
} else {
|
160
160
|
idStr += "id < ? "
|
161
|
-
idParams = append(
|
161
|
+
idParams = append(idParams, _p.FirstId)
|
162
162
|
}
|
163
163
|
case "current":
|
164
164
|
// trick to make Where function work
|
165
165
|
if _p.PageNum == 0 && _p.FirstId == 0 && _p.LastId == 0 {
|
166
166
|
idStr += "id > ? "
|
167
|
-
idParams = append(
|
167
|
+
idParams = append(idParams, 0)
|
168
168
|
} else {
|
169
169
|
if strings.ToLower(_p.Order["id"]) == "desc" {
|
170
170
|
idStr += "id <= ? AND id >= ? "
|
171
|
-
idParams = append(
|
171
|
+
idParams = append(idParams, _p.FirstId, _p.LastId)
|
172
172
|
} else {
|
173
173
|
idStr += "id >= ? AND id <= ? "
|
174
|
-
idParams = append(
|
174
|
+
idParams = append(idParams, _p.FirstId, _p.LastId)
|
175
175
|
}
|
176
176
|
}
|
177
177
|
case "next":
|
178
178
|
if strings.ToLower(_p.Order["id"]) == "desc" {
|
179
179
|
idStr += "id < ? "
|
180
|
-
idParams = append(
|
180
|
+
idParams = append(idParams, _p.LastId)
|
181
181
|
} else {
|
182
182
|
idStr += "id > ? "
|
183
|
-
idParams = append(
|
183
|
+
idParams = append(idParams, _p.LastId)
|
184
184
|
}
|
185
185
|
}
|
186
|
+
if _p.WhereString != "" {
|
187
|
+
idStr = " AND " + idStr
|
188
|
+
}
|
186
189
|
return
|
187
190
|
}
|
188
191
|
|