+get '/:grito' do
+ @grito = Grito.first(:id => params[:grito].to_i(36))
+ raise "Invalid Post" if @grito.nil?
+
+ @markdown = RDiscount.new(@grito.text)
+
+ haml :grito
+end
+
+error do
+ haml :error
+end
+
+DataMapper.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita')
+class Grito
+ include DataMapper::Resource
+ property :id, Serial
+ property :title, String
+ property :text, Text
+ property :created_at, DateTime
+
+ validates_presence_of :title, :message => "· Debes incluír un título."
+ validates_presence_of :text, :message => "· ¡No escribiste contenido!"
+
+ def gethash()
+ self.id.to_s(36)
+ end