Commit 689608e4cb7295d462429c328f971709f226e385

Authored by Arthur Neves
1 parent c96727bd
Exists in master and in 1 other branch production

Work around mongoid empty in query

Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
app/models/notice.rb
@@ -30,7 +30,11 @@ class Notice @@ -30,7 +30,11 @@ class Notice
30 30
31 scope :ordered, ->{ order_by(:created_at.asc) } 31 scope :ordered, ->{ order_by(:created_at.asc) }
32 scope :reverse_ordered, ->{ order_by(:created_at.desc) } 32 scope :reverse_ordered, ->{ order_by(:created_at.desc) }
33 - scope :for_errs, lambda {|errs| where(:err_id.in => errs.all.map(&:id))} 33 + scope :for_errs, Proc.new { |errs|
  34 + if (ids = errs.all.map(&:id)) && ids.present?
  35 + where(:err_id.in => ids)
  36 + end
  37 + }
34 38
35 def user_agent 39 def user_agent
36 agent_string = env_vars['HTTP_USER_AGENT'] 40 agent_string = env_vars['HTTP_USER_AGENT']