Skip to content

Instantly share code, notes, and snippets.

@dlt
Created May 5, 2012 05:49
Show Gist options
  • Save dlt/2600179 to your computer and use it in GitHub Desktop.
Save dlt/2600179 to your computer and use it in GitHub Desktop.
require "rubygems"
require "sinatra"
require "erb"
require "digest/md5"
require "uri"
require "data_mapper"
set :static, true
set :public_folder, "#{File.dirname(__FILE__)}/public"
set :views, "#{File.dirname(__FILE__)}/views"
class Flower
include DataMapper::Resource
property :id, Serial
property :value, String
end
configure do
# setting up database
DataMapper.setup(:default, ENV["SHARED_DATABASE_URL"])
DataMapper.finalize
DataMapper.auto_migrate!
end
get "/" do
erb :"main", :layout => false
end
get "/:id" do
Flower.first_or_create(value: params[:id].strip)
redirect "/"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment