From: Toshi MARUYAMA Date: Mon, 9 Nov 2020 13:25:19 +0000 (+0000) Subject: use "do end" instead of {} at ActiveRecord scope lambda of app/models/user.rb X-Git-Tag: 4.2.0~500 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b2e81eecf25dba60f19f74b82f70d590f88330ee;p=redmine.git use "do end" instead of {} at ActiveRecord scope lambda of app/models/user.rb git-svn-id: http://svn.redmine.org/redmine/trunk@20318 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/user.rb b/app/models/user.rb index c859994ed..2f88713ca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,27 +132,27 @@ class User < Principal after_save :update_notified_project_ids, :destroy_tokens, :deliver_security_notification after_destroy :deliver_security_notification - scope :admin, lambda {|*args| + scope :admin, (lambda do |*args| admin = args.size > 0 ? !!args.first : true where(:admin => admin) - } - scope :in_group, lambda {|group| + end) + scope :in_group, (lambda do |group| group_id = group.is_a?(Group) ? group.id : group.to_i where("#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id) - } - scope :not_in_group, lambda {|group| + end) + scope :not_in_group, (lambda do |group| group_id = group.is_a?(Group) ? group.id : group.to_i where("#{User.table_name}.id NOT IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id) - } + end) scope :sorted, lambda {order(*User.fields_for_order_statement)} - scope :having_mail, lambda {|arg| + scope :having_mail, (lambda do |arg| addresses = Array.wrap(arg).map {|a| a.to_s.downcase} if addresses.any? joins(:email_addresses).where("LOWER(#{EmailAddress.table_name}.address) IN (?)", addresses).distinct else none end - } + end) def set_mail_notification self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?