如何让 Sinatra 返回与今天日期匹配的记录?
我的 Sinatra 应用程序是笔记的集合。每个笔记都被分配了一个(未来)发布日期:
class Note
include DataMapper::Resource
property :id, Serial
property :publish_date, Date
property :content, String
end
我想创建一个仅显示今天笔记的路线,基于publish_date:
get '/' do
...
erb :today
end
我想要的笔记可以使用 note.publish_date.to_s = Date 找到.today.to_s 但我似乎无法弄清楚使其工作的语法。预先感谢您的设置是直的!
My 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许是这样
?
Something like
perhaps?