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.

Reply via email to