]>
git.r.bdr.sh - rbdr/grita/blob - grita.rb
5 require 'dm-validations'
6 require 'dm-timestamps'
7 require 'dm-migrations'
11 set
:haml, :format => :html5
19 @grito = Grito
.new(:title => params
[:title], :text => params
[:text])
24 get
'/qr/:grito.png' do
25 tmpfile
= Tempfile
.new('tmp')
27 rpr_filepath
= tmpfile
.path +
'.png'
29 RQR
::QRCode.create
do |qr
|
30 qr
.save('http://grita.heroku.com/'+params
[:grito], rpr_filepath
)
33 buffer
= File
.open(rpr_filepath
).read
35 content_type
'image/png'
44 @grito = Grito
.first(:id => params
[:grito].to_i(36))
45 raise "Invalid Post" if @grito.nil?
53 DataMapper
.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita')
55 include DataMapper
::Resource
57 property
:title, String
59 property
:created_at, DateTime
61 validates_presence_of
:title, :message => "· Debes incluír un título."
62 validates_presence_of
:text, :message => "· ¡No escribiste contenido!"