Skip to content

Instantly share code, notes, and snippets.

@rbq
Created Nov 4, 2013
Embed
What would you like to do?
Animal
#!/usr/bin/env ruby
# coding: utf-8
require 'sinatra'
get '/:animal' do
@all_animals = ['Cat', 'Dog']
@animal = params[:animal] if @all_animals.include? params[:animal]
erb :index
end
__END__
@@ index
<h1><%= @animal || 'Unknown animal' %></h1>
<% if @animal %>
<img src="/<%= @animal %>.jpeg"/>
<% end %>
<% @all_animals.each do |animal| %>
<a href="/<%= animal %>"><%= animal %></a>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment