开发者

How can I get Sinatra to return a record matching today's date?

开发者 https://www.devze.com 2023-04-13 07:52 出处:网络
M开发者_运维百科y Sinatra app is a collection of notes. Each note is assigned a (future) date when it should be published:

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消