需要为 Rails 查找添加条件
我有包含以下字段的事件模型
string "name"
date "start_at"
date "end_at"
datetime "created_at"
datetime "updated_at"
string "trainer"
string "venue"
string "description"
boolean "holy"
integer "nxt"
,并且我还将包含培训师的事件中的假期保存为“0”,因此我需要找到事件表上的所有假期。专家可以给我一些实现这个的想法吗?
I have Event model which contains following fields
string "name"
date "start_at"
date "end_at"
datetime "created_at"
datetime "updated_at"
string "trainer"
string "venue"
string "description"
boolean "holy"
integer "nxt"
And I have also save holidays in the event that contains trainer as '0' so I need to find all the holidays on event table. Can expert give me some idea to implement this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Rails 有动态查找器。我不确定我是否正确理解您的问题,但此代码应该找到所有具有 trainer = 0 的事件。要查找一个假期,请使用:
要查找所有,请使用:
Rails has dynamic finders. I'm not sure if I understand your question correctly, but this code should find all Events that have trainer = 0. To find one holiday use:
To find all, use:
我猜您正在寻找类似的东西:
I guess that you are looking for something like: