Created
May 8, 2009 14:49
-
-
Save innovationfactory/108806 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'datamapper' | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Idea | |
include DataMapper::Resource | |
property :id, Serial | |
property :body, Text | |
end | |
DataMapper.auto_migrate! | |
get '/' do | |
"<p>" + | |
Idea.count.to_s + | |
Idea.all.inject(""){|sum, idea| sum << "#{idea.body} <br/>" } + | |
"</p>" + | |
'<form action="/" method="POST"> | |
<textarea name="idea" id="idea" rows="20"></textarea> | |
<br/><input type="submit" value="Submit"/> | |
</form>' | |
end | |
post '/' do | |
idea = Idea.new | |
idea.body = params["idea"] | |
idea.save | |
redirect '/' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment