Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Active Record relation is not returned in console?

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.

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 version: 3.1.0

RVM on 1.9.2

Thank you for your help!


EDIT: I have added a screenshot from the example. enter image description here

like image 297
hade Avatar asked Oct 04 '11 10:10

hade


1 Answers

You're doing everything right. You see query executed because console invokes inspect method on output. Try articles = Article.order("name").class

like image 142
Bohdan Avatar answered Sep 19 '22 05:09

Bohdan