4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/c80_yax/ajax_controller.rb', line 4
def fetch_items
@params = _make_params
case @params[:type]
when 'hit'
@itms = Item.where(is_hit: true)
.includes(item_props: {prop_name: [:uom, :related]})
.includes(:iphotos)
.includes(:strsubcat)
.paginate(page: @params[:page], per_page: @params[:per_page])
when 'offer'
@itms = Item.joins(:offers)
.includes(item_props: {prop_name: [:uom, :related]})
.includes(:iphotos)
.includes(:strsubcat)
.paginate(page: @params[:page], per_page: @params[:per_page])
when 'cat'
@itms = C80Yax::Item.includes(item_props: {prop_name: [:uom, :related]})
.includes(:iphotos)
.includes(strsubcat: :cats)
.where(c80_yax_cats: {slug: params[:slug] })
.paginate(page: @params[:page], per_page: @params[:per_page])
when 'strsubcat'
@itms = C80Yax::Item.includes(item_props: {prop_name: [:uom, :related]})
.includes(:iphotos)
.includes(:strsubcat)
.where(c80_yax_strsubcats: {slug: params[:slug] })
.paginate(page: @params[:page], per_page: @params[:per_page])
end
@items = ItemDecorator.decorate_collection(@itms)
end
|