Skip to content

Instantly share code, notes, and snippets.

@joefiorini
Created September 26, 2008 16:50
Show Gist options
  • Save joefiorini/13148 to your computer and use it in GitHub Desktop.
Save joefiorini/13148 to your computer and use it in GitHub Desktop.
class ShowsController < ApplicationResourceController
def route_name
'show'
end
def resource_name
'show'
end
def model_name
'show'
end
def object_name
'show'
end
def collection
if params[:nowplaying]
@collection ||= Show.nowplaying
elsif params[:upcoming]
@collection ||= Show.upcoming
else
@collection ||= end_of_association_chain.find(:all)
end
end
def object
if params[:id] =~ /^\d+$/
@show ||= Show.find params[:id]
elsif params[:id]
@show ||= Show.find_by_name params[:id]
else
@object
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment