Skip to content

Commit

Permalink
Task #1: Globalize attributes support
Browse files Browse the repository at this point in the history
If the atttribute is detected as translated through globalize we include the current translation and query the translation table
  • Loading branch information
brenes committed Feb 24, 2016
1 parent d4a9b6b commit 08880dc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/postgres_ext/serializers/active_model/array_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def _include_relation_in_root(relation, *args)
relation_query = relation_query.select Arel::Nodes::As.new Arel.sql(serializer_class.send("#{name}__sql")), Arel.sql(name.to_s)
elsif klass.respond_to? "#{name}__sql"
relation_query = relation_query.select Arel::Nodes::As.new Arel.sql(klass.send("#{name}__sql")), Arel.sql(name.to_s)
elsif klass.respond_to?(:translated?) && klass.translated?(name)
relation_query = relation_query.with_translations(Globalize.locale)
relation_query = relation_query.select(klass::Translation.arel_table[name])
else
relation_query = relation_query.select(relation_query_arel[name])
end
Expand Down

0 comments on commit 08880dc

Please sign in to comment.