RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: goganchic
Site: http://linux.vsevteme.ru
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"
comments
parent_id
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
Why to_sql function works like this:
Comment.root.to_sql
=> "SELECT
comments
.* FROMcomments
WHEREcomments
.parent_id
IS NULL ORDER BY created_at desc"Comment.includes(:user).to_sql
=> "SELECT
comments
.* FROMcomments
"in the second example real sql query should differs from result shown by to_sql function