简体   繁体   English

:select在Rails 2.3中使用:include或类似的activerecord功能

[英]:select with :include or similar activerecord functionality in rails 2.3

Does anyone have an elegant way of doing an activerecord call containing a :select AND an :include statement? 有没有人有一个优雅的方式来进行包含:select和:include语句的activerecord调用? I have seen a lot of really old information about getting this working in rails 2.3 and I also know that it is functional in rails 3 but unfortunately not in activerecord core as of 2.3. 我已经看到了很多有关在Rails 2.3中运行此功能的非常古老的信息,而且我也知道它在Rails 3中有效,但不幸的是,在2.3版中,它不在activerecord核心中。 I am using rails 2.3.4 ruby 1.8.7 我正在使用Rails 2.3.4 ruby​​ 1.8.7

Parent.find(:all, :select => "foo, bar", :include => :child)

有关更多信息,请参见http://apidock.com/rails/ActiveRecord/Base/find/class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM