开发者

ActiveRecord join with new 1.9 hash syntax

开发者 https://www.devze.com 2023-04-01 18:27 出处:网络
I have an AR query that looks like this user.books.joins(:authors).where(:authors => {:id => [1,2,3]}, :title => \'blah\')

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

精彩评论

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

关注公众号