Skip to content

Instantly share code, notes, and snippets.

@caius
Forked from oleander/gist:480770
Created July 18, 2010 22:44
Show Gist options
  • Save caius/480775 to your computer and use it in GitHub Desktop.
Save caius/480775 to your computer and use it in GitHub Desktop.
def show
# By making it a bang (!) finder it raises RecordNotFound if nothing's found.
@movie = Movie.find_by_channel_id!(params[:id])
# We found something, render it as XML
respond_to do |format|
format.xml { render :xml => @movie }
end
# Oh noes. Nothing found. Tell ze user with a 404.
rescue ActiveRecord::RecordNotFound
respond_to do |f|
# Check what to actually render as XML here. Don't think a string is right.
f.xml { render :xml => "Not Found", :status => :not_found }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment