With that said, I've switched to the set_graph_aliases method and it works as advertised.
When I read your response last night and saw this: select(:id=>[:articles, :id], :slug=>[:articles, :slug], :title=>[:en, :title], :summary=>[:en, :summary]) I presumed that FORM (passing the hash of arrays) was setting graph aliases internally or something. (I promise I didn't just cut and paste code without reading the rest!) On Oct 8, 10:18 am, Jeremy Evans <[email protected]> wrote: > On Oct 7, 9:04 pm, cult hero <[email protected]> wrote: > > > > > > > Ahh. Okay. > > > I actually prefer the second method. However, I dunno why but it > > doesn't quite work for me. It might be because I'm running Ruby 1.9. > > > This does, I'm guessing, the almost the same thing: > > > Article.order(:slug).eager_graph(:en).select(:articles__id, > > :articles__slug, :en__title, :en__summary).all > > > Works like a charm. On my setup the code you gave me produces: > > > (0.021723s) SELECT "id" AS "[:articles, :id]", "slug" AS > > "[:articles, :slug]", "title" AS "[:en, :title]", "summary" AS > > "[:en, :summary]" FROM "articles" INNER JOIN "article_contents_en" AS > > "en" ON (("en"."article_id" = "articles"."id") AND ("en"."available" > > IS TRUE)) ORDER BY "slug" > > NoMethodError: undefined method `pk_or_nil' for nil:NilClass > > That's because even though I mentioned set_graph_aliases, I used > select in the code. No cookie for me. With set_graph_aliases it > should work. If select works for you, it's certainly simpler. Note > that using select after eager_graph isn't supported, so you can keep > the pieces if stuff breaks. :) > > Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
