def top
@new_comics = Comic.find(:all,
- :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 5
+ :include => :author, :conditions => ['visible > 0'], :order => 'updated_at desc', :limit => 5
)
@new_pictures = OriginalPicture.find(:all,
:include => [:artist, :license, :resource_picture], :order => 'updated_at', :limit => 5
end
def play
- @comic = Comic.find(params[:id], include: [:author, {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}], order: 'panels.t')
-
+ @comic = Comic.play(params[:id])
respond_to do |format|
format.html # index.html.erb
format.json {
- render :json => @comic.to_json(
- :include => [:author, {
- :panels => {:include => {
- :panel_pictures => {:include => :resource_picture},
- :balloons => {:include => :speaches}
- }}
- }]
- )
+ render :json => @comic.to_json_play
}
format.jsonp {
- render :json => "callback(" + @comic.to_json(
- :include => {
- :panels => {:include => {
- :panel_pictures => {:include => :resource_picture},
- :balloons => {:include => :speaches}
- }}
- }
- ) + ");"
+ render :json => "callback(" + @comic.to_json_play + ");"
}
end
end