Remove weird unused begin/end block in ItemsController
This commit is contained in:
parent
19ebf4d78a
commit
bdefeb53d6
1 changed files with 42 additions and 44 deletions
|
@ -4,55 +4,53 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if @query
|
if @query
|
||||||
begin
|
if params[:per_page]
|
||||||
if params[:per_page]
|
per_page = params[:per_page].to_i
|
||||||
per_page = params[:per_page].to_i
|
per_page = 50 if per_page && per_page > 50
|
||||||
per_page = 50 if per_page && per_page > 50
|
else
|
||||||
else
|
per_page = 30
|
||||||
per_page = 30
|
end
|
||||||
end
|
|
||||||
|
|
||||||
@items = @query.results.paginate(
|
@items = @query.results.paginate(
|
||||||
page: params[:page], per_page: per_page)
|
page: params[:page], per_page: per_page)
|
||||||
assign_closeted!
|
assign_closeted!
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
@campaign = Fundraising::Campaign.current rescue nil
|
@campaign = Fundraising::Campaign.current rescue nil
|
||||||
if @items.count == 1
|
if @items.count == 1
|
||||||
redirect_to @items.first
|
redirect_to @items.first
|
||||||
else
|
else
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
format.json {
|
format.json {
|
||||||
render json: {
|
render json: {
|
||||||
items: @items.as_json(
|
items: @items.as_json(
|
||||||
methods: [:nc?, :pb?, :owned?, :wanted?],
|
methods: [:nc?, :pb?, :owned?, :wanted?],
|
||||||
),
|
),
|
||||||
appearances: load_appearances.as_json(
|
appearances: load_appearances.as_json(
|
||||||
include: {
|
include: {
|
||||||
swf_assets: {
|
swf_assets: {
|
||||||
only: [:id, :remote_id, :body_id],
|
only: [:id, :remote_id, :body_id],
|
||||||
include: {
|
include: {
|
||||||
zone: {
|
zone: {
|
||||||
only: [:id, :depth, :label],
|
only: [:id, :depth, :label],
|
||||||
methods: [:is_commonly_used_by_items],
|
methods: [:is_commonly_used_by_items],
|
||||||
},
|
},
|
||||||
restricted_zones: {
|
restricted_zones: {
|
||||||
only: [:id, :depth, :label],
|
only: [:id, :depth, :label],
|
||||||
methods: [:is_commonly_used_by_items],
|
methods: [:is_commonly_used_by_items],
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: [:urls, :known_glitches],
|
|
||||||
},
|
},
|
||||||
}
|
methods: [:urls, :known_glitches],
|
||||||
),
|
},
|
||||||
total_pages: @items.total_pages,
|
}
|
||||||
query: @query.to_s,
|
),
|
||||||
}
|
total_pages: @items.total_pages,
|
||||||
|
query: @query.to_s,
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
end
|
end
|
||||||
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
|
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
|
||||||
@items = Item.find(params[:ids])
|
@items = Item.find(params[:ids])
|
||||||
|
|
Loading…
Reference in a new issue