How can I get Sinatra to return a record matching today's date?
M开发者_运维百科y Sinatra app is a collection of notes. Each note is assigned a (future) date when it should be published:
class Note
include DataMapper::Resource
property :id, Serial
property :publish_date, Date
property :content, String
end
I'd like to create a route that will display only today's note, based on the publish_date:
get '/' do
...
erb :today
end
The note I want might be found using note.publish_date.to_s = Date.today.to_s but I can't seem to figure out the syntax to make this work. Thanks in advance for setting be straight!
Something like
get '/' do
Note.first(:publish_date => Date.today)
erb :today
end
perhaps?
精彩评论