Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Egor Baranov's Profile

GitHub User: goganchic

Site: http://linux.vsevteme.ru

Comments by Egor Baranov

Avatar

Why to_sql function works like this:

Comment.root.to_sql
=> "SELECT comments.* FROM comments WHERE comments.parent_id IS NULL ORDER BY created_at desc"

Comment.includes(:user).to_sql
=> "SELECT comments.* FROM comments"

in the second example real sql query should differs from result shown by to_sql function