为什么活动记录关系不在控制台回来? [英] Why Active Record relation is not returned in console?
问题描述
我终于开始升级我的Rails应用从2.3.8到3.1.0。我在看RailsCasts( http://railscasts.com/episodes/ 202-主动记录查询功能于轨道-3 )有关活动记录的查询。
I have finally started upgrading my Rails apps from 2.3.8 to 3.1.0. I was watching RailsCasts (http://railscasts.com/episodes/202-active-record-queries-in-rails-3) about Active Record queries.
当我打开控制台(轨c)和做的查询与此类似:
When I open up the console (rails c) and do query similar to this:
articles = Article.order("name")
而不是返回活动记录的关系,我看执行查询。我在做什么错在这里?
Instead of returning Active Record relations, I see the query executed. What am I doing wrong here?
Rails的版本:3.1.0
Rails version: 3.1.0
RVM在1.9.2
RVM on 1.9.2
感谢您的帮助!
编辑:我已增加了从例子截图。
I have added a screenshot from the example.
推荐答案
您正在做的一切权利。你看到的查询执行,因为控制台调用检查
方法上输出。尝试文章= Article.order(名)。类
You're doing everything right. You see query executed because console invokes inspect
method on output. Try articles = Article.order("name").class
这篇关于为什么活动记录关系不在控制台回来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!