查看ORM实际生成的sql Posted on 2015-05-06 In Rails , Ruby 可以调用to_sql方法察看实际ORM输出出來的SQL,例如Event.open_public.recent_three_days.to_sql Post.where(author_id: 1).order("id desc").limit(3).to_sql # SELECT `posts`.* FROM `posts` WHERE `posts`.`author_id` = 1 ORDER BY id desc LIMIT 3