I'm trying to run a query on table Testimonials which has a Translation Table TestimonialTranslations.
The Following query works like a charm:
Testimonial.with_translations(I18n.locale).where(:id => params[:id]).first
When I change the query to:
Testimonial.with_translations(I18n.locale).where(:alias => "test").first
It doesn't return any values?
A record exists where the where class is 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">]
I know 100% sure that the language is "nl" and that it returns a query when I run:
Testimonial.with_translations(I18n.locale)
These are my specs:
EDIT 1:
I'm going to leave this open for a while but as far as I can see it is not possible to add a where to the with_translations query that will go and look in the translation table.
With this knowledge I will need to do 2 querys.
Did you try with with_translated_attribute
?