Skip to content

Instantly share code, notes, and snippets.

@sr
Forked from bmizerany/from.rb
Created December 14, 2008 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sr/35591 to your computer and use it in GitHub Desktop.
Save sr/35591 to your computer and use it in GitHub Desktop.
get '/:id' do
@vent = Vent.get(params[:id])
erb :show
end
# show post
get '/:id.xml' do
@vent = Vent.get(params[:id])
builder :show
end
## Using ? will make the previous section optional
## NOTE the ? after the .
get '/:id.?:format?' do
@vent = Vent.get(params[:id])
case params[:format]
when 'xml'
builder :show
else
erb :show
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment