app/models/decidim/proposals/proposal.rb in decidim-proposals-0.24.3 vs app/models/decidim/proposals/proposal.rb in decidim-proposals-0.25.0.rc1
- old
+ new
@@ -335,11 +335,21 @@
WHEN state_published_at IS NOT NULL THEN 1
ELSE 0 END
")
end
+ def self.sort_by_translated_title_asc
+ field = Arel::Nodes::InfixOperation.new("->>", arel_table[:title], Arel::Nodes.build_quoted(I18n.locale))
+ order(Arel::Nodes::InfixOperation.new("", field, Arel.sql("ASC")))
+ end
+
+ def self.sort_by_translated_title_desc
+ field = Arel::Nodes::InfixOperation.new("->>", arel_table[:title], Arel::Nodes.build_quoted(I18n.locale))
+ order(Arel::Nodes::InfixOperation.new("", field, Arel.sql("DESC")))
+ end
+
ransacker :title do
- Arel.sql(%{("decidim_proposals_proposals"."title")::text})
+ Arel.sql(%{cast("decidim_proposals_proposals"."title" as text)})
end
ransacker :id_string do
Arel.sql(%{cast("decidim_proposals_proposals"."id" as text)})
end