質問編集履歴
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -151,3 +151,55 @@
|
|
151
151
|
|
152
152
|
|
153
153
|
よろしくお願い致します。
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
def index
|
162
|
+
|
163
|
+
@q = Customer.ransack(params[:q])
|
164
|
+
|
165
|
+
@customers = @q.result
|
166
|
+
|
167
|
+
@customers = @customers.where( id: last_call_customer_ids ) if !last_call_customer_ids.nil?
|
168
|
+
|
169
|
+
@customers = @customers.page(params[:page]).per(100)
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
def show
|
176
|
+
|
177
|
+
@customer = Customer.page(params[:page]).per(1)
|
178
|
+
|
179
|
+
@call = Call.new
|
180
|
+
|
181
|
+
@prev_customer = Customer.find_by(id: params[:id])
|
182
|
+
|
183
|
+
@next_customer = Customer.find_by(id: params[:id])
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
上記の形式の場合、pageを指定するとshowのviewsの中にエラーが出てきてしまいます。
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
ActionView::Template::Error (undefined method `company' for #<Customer::ActiveRecord_Relation:0x00007f9cf8afddd0>
|
194
|
+
|
195
|
+
Did you mean? compact):
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
また、showのpaginateの指定は以下となります。
|
200
|
+
|
201
|
+
```
|
202
|
+
|
203
|
+
<%= paginate @customer, class: "prev btn btn-danger" %>
|
204
|
+
|
205
|
+
```
|