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
|
# File 'app/controllers/selectors.rb', line 6
def show
partials do
show :search
show :tags
end
respond_to do |f|
if @model
require_permission :view, @model
@page, @per_page = (params.page || 1).to_i, Models::Item::PER_PAGE
query = Models::Item.where(
viewers: {_in: rad.user.major_roles},
dependent: {_exists: false}
).sort([:created_at, -1]).paginate(@page, @per_page)
tags = (@model.query + selected_tags).uniq
query = query.where tags: {_all: tags} unless tags.empty?
@model.items = query.all
f.html{@html_title = @model.name}
f.json{render json: @model}
else
f.html{render :not_found}
f.json{render :not_found}
end
end
end
|