當我試圖通過指定藝術家讓所有的音頻歌曲中獲取數據的時候,我得到錯誤:ActiveRecord的StatementInvalid與globalize3
ActiveRecord::StatementInvalid: PGError: ERROR: column reference "artist" is ambiguous
LINE 1: ... AND (audio_translations.artist IS NOT NULL) AND (artist = '...
^
: SELECT "audios"."id" AS t0_r0, "audios"."audio_genre_id" AS t0_r1, "audios"."song" AS t0_r2, "audios"."artist" AS t0_r3, "audios"."file_id" AS t0_r4, "audios"."photo_id" AS t0_r5, "audios"."description" AS t0_r6, "audios"."position" AS t0_r7, "audios"."created_at" AS t0_r8, "audios"."updated_at" AS t0_r9, "audios"."date" AS t0_r10, "audio_translations"."id" AS t1_r0, "audio_translations"."audio_id" AS t1_r1, "audio_translations"."locale" AS t1_r2, "audio_translations"."artist" AS t1_r3, "audio_translations"."song" AS t1_r4, "audio_translations"."description" AS t1_r5, "audio_translations"."created_at" AS t1_r6, "audio_translations"."updated_at" AS t1_r7 FROM "audios" LEFT OUTER JOIN "audio_translations" ON "audio_translations"."audio_id" = "audios"."id" WHERE "audio_translations"."locale" = 'en' AND (audio_translations.artist IS NOT NULL) AND (artist = 'Andy')
我用下面的語句AR:
Audio.with_translations(I18n.locale).find(:all, :conditions => ["artist = ?", 'Andy'])
它工作沒有with_translations
方法:
>> Audio.find(:all, :conditions => ["artist = ?", 'Andy'])
=> [#<Audio id: 10, audio_genre_id: 1, song: "My heart, my life", artist: "Andy", file_id: 1, photo_id: nil, description: "...", position: 2, created_at: "2011-07-12 07:24:43", updated_at: "2011-07-12 08:31:21", date: "2011-07-12 07:24:00">]