I want to order some records of a model that has a relation to another model (with translated attributes). Here an example:
Now, I want to order all projects by its tasks name. How can I write this scope? How can I join the translation table in Rails like method with_translation in gem globalize (https://github.com/globalize/globalize/blob/eccb924ac9641b52399f22525b0e3ec004739f4c/lib/globalize/active_record/class_methods.rb) but from related object Project?
> Project.all.joins(:tasks) ... (how to include task translation table) ...
I believe the task_translations
is directly related to tasks
and you can query it like so:
Project.joins(tasks: :translations)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With