Rails where子句之间在MySQL中不起作用

马克·洛克利尔

我在rails中有以下查询...

@registrations = Registration.where(Orientation.where(class_date: @start_date..@end_date))

查询本身不会引发错误,但是,如果我尝试检查@registrations对变量执行任何操作,则会收到错误...

Cannot visit ActiveRecord::Relation

有任何想法吗?

Xlembouras

Orientation.where(class_date: @start_date..@end_date)

您喜欢的范围查询吗

SELECT * FROM orientations WHERE class_date BETWEEN <start_date> AND <end_date>

更新

Registration.where(created_at: @start_date..@end_date).
  joins(:orientation).
  where('orientations.created_at' => @start_date..@end_date)

将做出以下SQL我认为您需要的

SELECT registrations.* FROM registrations INNER JOIN orientations ON orientations.id = registrations.orientation_id WHERE (registrations.created_at BETWEEN '2014-02-17 16:01:41' AND '2014-02-19 16:01:41') AND (orientations.created_at BETWEEN '2014-02-17 16:01:41' AND '2014-02-19 16:01:41')

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Rails渴望加载(包括),where子句不起作用?

来自分类Dev

where子句在mysql中不起作用

来自分类Dev

Rails .where() 查询不起作用

来自分类Dev

邮件在Rails 4.1中不起作用

来自分类Dev

Javascript在Rails中不起作用

来自分类Dev

jQuery在Rails中不起作用

来自分类Dev

Rails中的链接不起作用

来自分类Dev

Mailcatcher在Rails中不起作用

来自分类Dev

递归方法在Rails中不起作用

来自分类Dev

提交方法在Rails中不起作用

来自分类Dev

querySelectorAll 在 Rails 5 中不起作用

来自分类Dev

Where 子句在我的 mysql 查询中不起作用

来自分类Dev

mysql where子句不起作用

来自分类Dev

mysql where子句不起作用

来自分类Dev

rails --api不起作用

来自分类Dev

Rails渲染不起作用

来自分类Dev

rails --api不起作用

来自分类Dev

mysql + ruby on rails + linux mint =不起作用

来自分类Dev

选择选项在使用MaterializeCSS的Rails中不起作用

来自分类Dev

before_create在Rails中不起作用

来自分类Dev

图像路径生产参考在Rails 4中不起作用

来自分类Dev

Bootstrap-sass在Rails App中不起作用

来自分类Dev

Rails`image_path`在CSS文件中不起作用

来自分类Dev

Rails 4中的语言环境回退不起作用

来自分类Dev

Bootstrap解雇在Ruby on Rails中不起作用

来自分类Dev

Searchkick word_start在Rails中不起作用

来自分类Dev

Bootstrap在Rails应用程序中不起作用

来自分类Dev

Rails应用程序中的搜索表单不起作用

来自分类Dev

Rails 4.1.8上的LiveReload在Chrome或Safari中不起作用