restrict item swf assets by fitting body id
This commit is contained in:
parent
82c2ff6206
commit
743ec4d910
2 changed files with 7 additions and 3 deletions
|
@ -1,10 +1,13 @@
|
||||||
class SwfAssetsController < ApplicationController
|
class SwfAssetsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
if params[:item_id]
|
if params[:item_id]
|
||||||
@swf_assets = Item.find(params[:item_id]).swf_assets.for_json.all
|
@swf_assets = Item.find(params[:item_id]).swf_assets
|
||||||
|
if params[:body_id]
|
||||||
|
@swf_assets = @swf_assets.fitting_body_id(params[:body_id])
|
||||||
|
end
|
||||||
elsif params[:pet_type_id]
|
elsif params[:pet_type_id]
|
||||||
@swf_assets = PetType.find(params[:pet_type_id]).pet_states.first.swf_assets.for_json.all
|
@swf_assets = PetType.find(params[:pet_type_id]).pet_states.first.swf_assets
|
||||||
end
|
end
|
||||||
render :json => @swf_assets
|
render :json => @swf_assets.for_json.all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ class SwfAsset < ActiveRecord::Base
|
||||||
delegate :depth, :to => :zone
|
delegate :depth, :to => :zone
|
||||||
|
|
||||||
scope :for_json, includes(:zone)
|
scope :for_json, includes(:zone)
|
||||||
|
scope :fitting_body_id, lambda { |body_id| where(arel_table[:body_id].in([body_id, 0])) }
|
||||||
|
|
||||||
def local_url
|
def local_url
|
||||||
uri = URI.parse(url)
|
uri = URI.parse(url)
|
||||||
|
|
Loading…
Reference in a new issue