Ruby on Rails Wednesday, April 28, 2010

Sharagoz wrote:
> If you just want to use activerecord without writing inner joins
> manually you can do
> @decks_with_aces = Deck.all(:joins => :cards, :conditions =>
> "cards.rank = ''Ace")
> @decks_with_kings = Deck.all(:joins => :cards, :conditions =>
> "cards.rank = ''King")
> @decks_with_aces_and_kings = @decks_with_aces & @decks_with_kings
>
> That basically puts all decks with kings in an array, the same for
> aces, and then uses the arrays & method to find elements common in
> both.
> It's not perfect performance wise, but it works

Thanks, but as you suggest the performance cost is prohibitive for me.
ben

--
Posted via http://www.ruby-forum.com/.

--
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.

No comments:

Post a Comment