What is the recommended way to use table aliases with
ActiveRecord::Relation these days?
In prior versions of Rails, this would work:

assume (pseudo code):
model A
has_many b's

model B

at = B.arel_table
atalias = at.alias(at.name + "_1")

= 'foo'").where("b_1.widget = 'bar'"). ...
^ probably should be "on"

now in 3.1.1: passing in a arel_table into join ... returns a String,
not a relation, breaking the ActiveRecord::Relation chain.

In short: if we want to find A's where they contain *both* a B.widget
'foo' and a B.widget 'bar' ...
how do we do this without writing custom SQL ?

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedNov 3, '11 at 11:46p
activeNov 3, '11 at 11:46p

1 user in discussion

Solas: 1 post



site design / logo © 2022 Grokbase