summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/occurrence.rb2
-rw-r--r--app/models/page.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/app/models/occurrence.rb b/app/models/occurrence.rb
index 143124f..777be24 100644
--- a/app/models/occurrence.rb
+++ b/app/models/occurrence.rb
@@ -35,7 +35,7 @@ class Occurrence < ApplicationRecord
35 self.create( 35 self.create(
36 :start_time => occurrence, 36 :start_time => occurrence,
37 :end_time => (occurrence + duration), 37 :end_time => (occurrence + duration),
38 :node_id => node.id, 38 :node_id => node&.id,
39 :event_id => event.id 39 :event_id => event.id
40 ) 40 )
41 end 41 end
diff --git a/app/models/page.rb b/app/models/page.rb
index 385b3f6..c982c2e 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -63,15 +63,15 @@ class Page < ApplicationRecord
63 end 63 end
64 end 64 end
65 65
66 direction = %w[ASC DESC].include?(options[:order_direction]&.upcase) ? options[:order_direction].upcase : "ASC"
67
66 if options[:order_by] == "title" 68 if options[:order_by] == "title"
67 return scope 69 return scope
68 .joins(:translations) 70 .order(Arel.sql("(SELECT pt.title FROM page_translations pt WHERE pt.page_id = pages.id AND pt.locale = #{ActiveRecord::Base.connection.quote(I18n.locale.to_s)}) #{direction}"))
69 .where(page_translations: { locale: I18n.locale })
70 .order("page_translations.title #{options[:order_direction]}")
71 .paginate(:page => page, :per_page => options[:limit]) 71 .paginate(:page => page, :per_page => options[:limit])
72 end 72 end
73 73
74 scope.order("#{options[:order_by]} #{options[:order_direction]}") 74 scope.order("#{options[:order_by]} #{direction}")
75 .paginate(:page => page, :per_page => options[:limit]) 75 .paginate(:page => page, :per_page => options[:limit])
76 end 76 end
77 77