Post.find(:all, :select => "DISTINCT author")
[#<Post author: nil>, #<Post author: nil>, #<Post author: nil>, #<Post author: nil>, #<Post author: nil>]
を返します。select distinct returns nil(globalize3)
ただし、SQL要求SELECT DISTINCT author FROM posts;
は期待どおりに機能します。
私はglobalize3を使用しています。 Post.select('DISTINCT author').with_translations('en')
はすべてのレコードを返します。
Post Load (0.5ms) SELECT "posts"."id" AS t0_r0, "posts"."description" AS t0_r1, "posts"."position" AS t0_r2, "posts"."created_at" AS t0_r3, "posts"."updated_at" AS t0_r4, "posts"."date"
AS t0_r5, "post_translations"."id" AS t1_r0, "post_translations"."post_id" AS t1_r1, "post_translations"."locale" AS t1_r2, "post_translations"."author"
AS t1_r3, "post_translations"."description" AS t1_r4, "post_translations"."created_at" AS t1_r5, "post_translations"."updated_at"
AS t1_r6 FROM "posts" LEFT OUTER JOIN "post_translations" ON "post_translations"."post_id" = "posts"."id" WHERE "post_translations"."locale" = 'en'
AND (post_translations.author IS NOT NULL)
がどのように異なる値のみを選択することができます。ここで
は、それがログのですか?
をして、ログのチャンクを投稿してください両方のリクエスト – Bohdan
が更新されました。これは最初のリクエストです: 'ActionView :: Template :: Error(ルートが{:action =>" show "、:controller =>" posts "、id =>#<投稿者:nil>}):' – NARKOZ