翻訳テーブル TestimonialTranslations を持つテーブル Testimonials に対してクエリを実行しようとしています。
次のクエリは魅力のように機能します。
Testimonial.with_translations(I18n.locale).where(:id => params[:id]).first
クエリを次のように変更すると:
Testimonial.with_translations(I18n.locale).where(:alias => "test").first
値が返されませんか?
where クラスが true であるレコードが存在します。
=> [#<Testimonial id: 1, title: "Test", person: "", image_uid: nil, content: "<p>zfzefzfLorem ipsum dolor sit amet, consectetur a...", interest_group: "", created_at: "2015-01-15 11:48:11", updated_at: "2015-01-15 11:48:11", job: "", overview: true, content_short: "<p>Lorem ipsum dolor sit amet, consectetur adipisci...", hidden: false, hide_image: false, alias: "test">]
言語が「nl」であり、実行するとクエリが返されることを100%確信しています:
Testimonial.with_translations(I18n.locale)
これらは私の仕様です:
- ruby 1.9.3p550 (2014-10-27 リビジョン 48165) [x86_64-darwin13.4.0]
- レール 3.2.19
編集1:
しばらくこれを開いたままにしておきますが、私が見る限り、with_translations クエリに where を追加して変換テーブルを調べることはできません。
この知識があれば、2 つのクエリを実行する必要があります。