Skip to content

Instantly share code, notes, and snippets.

@ocean
Created January 27, 2010 05:42
Show Gist options
  • Save ocean/287566 to your computer and use it in GitHub Desktop.
Save ocean/287566 to your computer and use it in GitHub Desktop.
# sweet bro.
%w(rubygems sinatra haml sass dm-core dm-timestamps).each {|gem| require gem}
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/dev.db")
DataMapper.auto_upgrade!
get '/' do
haml :index
end
post '/' do
@customer = Customer.new(:email => params[:email])
@thanks = @customer.save
haml :index
end
class Customer
include DataMapper::Resource
property :id, Integer, :serial => true
property :email, Text, :nullable => false
property :created_at, DateTime
property :updated_at, DateTime
end
__END__
@@ index
!!!
%html
%head
%title Hello
%body
%h1 Intro...
- if @thanks
%p oh hey thanks
- else
%p yeah we're not live yet, let's do the thing where you leave your email:
%form{:method => 'post'}
%input{:name => 'email'}
%button{:type => 'submit'} Send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment