开发者

ActiveRecord join with new 1.9 hash syntax

I have an AR query that looks like this

user.books.joins(:authors).where(:authors => {:id => [1,2,3]}, :title => 'blah')

This is just an example but notice when I specify conditions on the joined table I'm using the pre-1.9 hash syntax. ie. :authors => {:id => [1,2,3]}

Is there a way to do this same query with the 1.9 hash syntax?

It's pretty readable as it is and using the 1.9 syntax will probably make it less so开发者_如何学Go. But I'm still curious if it's possible and what it would look like.


This should perfectly with the the new syntax:

user.books.joins(:authors).where(authors: {id: [1,2,3]}, title: 'blah')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜