Emi Matchu
7af1a97161
I'm not sure why I had marked this as TODO before? Maybe I'm missing something? But for now I'll just wire it in, I guess!
33 lines
945 B
Ruby
33 lines
945 B
Ruby
class AltStylesController < ApplicationController
|
|
def index
|
|
@alt_styles = AltStyle.includes(:species, :color, :swf_assets).
|
|
order(:species_id, :color_id)
|
|
|
|
if params[:species_id]
|
|
@species = Species.find(params[:species_id])
|
|
@alt_styles = @alt_styles.merge(@species.alt_styles)
|
|
end
|
|
|
|
# We're going to link to the HTML5 image URL, so make sure we have all the
|
|
# manifests ready!
|
|
SwfAsset.preload_manifests @alt_styles.map(&:swf_assets).flatten
|
|
|
|
respond_to do |format|
|
|
format.html { render }
|
|
format.json {
|
|
render json: @alt_styles.includes(swf_assets: [:zone]).as_json(
|
|
only: [:id, :species_id, :color_id, :body_id, :series_name,
|
|
:adjective_name, :thumbnail_url],
|
|
include: {
|
|
swf_assets: {
|
|
only: [:id, :body_id],
|
|
include: [:zone],
|
|
methods: [:urls, :known_glitches],
|
|
}
|
|
},
|
|
methods: [:series_name, :adjective_name, :thumbnail_url],
|
|
)
|
|
}
|
|
end
|
|
end
|
|
end
|