Joining the translations table caused duplicate records to appear.
Ordering with SQL is simply too hard because we need to consider
fallback locales.
Thanks Senén for providing most of the tests in the poll spec.
Since Globalize gem update to v5.2.0 we cannot override translations
anymore in the same way that before the update. Milestone::Translation
class removed in this commit were no longer loaded correctly when
translation class is retrieved by translation_class method provided by
Globalize. Here is the diff between both gem versions:
https://github.com/globalize/globalize/compare/v5.0.0...v5.2.0diff-a1370b109e0dd567545b072bc6447b8fR51
This problem is not happening on test environment but is throwing an
exception in other environments as it has not loaded the delegation
definition inside our custom translation class.
To fix this we added a new class method inside globalizable model
concern to allow to define method delegation on translations classes from
parent globalizable classes when needed without having to override
Translation classes.
Another way to properly load our custom Milestone::Translation class is
to place it inside parent model class.
Cambios para hacer commit:
modificado: app/controllers/admin/budget_headings_controller.rb
modificado: app/models/budget/heading.rb
nuevo archivo: app/views/admin/budget_headings/_errors.html.erb
nuevo archivo: app/views/admin/budget_headings/edit.js.erb
nuevo archivo: app/views/admin/budget_headings/update.js.erb
modificado: app/views/admin/budgets/_group.html.erb
nuevo archivo: app/views/admin/budgets/_heading.html.erb
nuevo archivo: app/views/admin/budgets/_heading_form.html.erb
modificado: config/locales/en/activerecord.yml
modificado: config/locales/es/activerecord.yml
modificado: spec/features/admin/budgets_spec.rb
modificado: spec/models/budget/heading_spec.rb
* What: We need to generate slug on Budget, Group and Heading classes, validating its unique for its scope
* How: Adding a presence and unique validation using Budget always as scope.