开发者

Get the SQL for a Rails 3 Association

开发者 https://www.devze.com 2023-03-09 14:49 出处:网络
I really like how in Rails 3 you can ask a scope for its SQL like this: User.admins.to_sql Is there any way to do the same thing with a has_many relation?:

I really like how in Rails 3 you can ask a scope for its SQL like this:

User.admins.to_sql

Is there any way to do the same thing with a has_many relation?:

User.first.jobs.to_sql

I've tried User.first.jobs.public开发者_运维技巧_methods.grep /sql/ and other tricks, but I haven't turned up anything.


User.first.jobs.scoped.to_sql

0

精彩评论

暂无评论...
验证码 换一张
取 消