mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
c196ca72a0
Since 31ffbf8d
, finder methods no longer raise `RangeError`. So
`StatementCache#execute` is the only place to raise the exception for
finder queries.
`StatementCache` is used for simple equality queries in the codebase.
This means that if `StatementCache#execute` raises `RangeError`, the
result could always be regarded as empty.
So `StatementCache#execute` just return nil in that range error case,
and treat that as empty in the caller side, then we can avoid catching
the exception in much places.
25 lines
594 B
Ruby
25 lines
594 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Reference < ActiveRecord::Base
|
|
belongs_to :person
|
|
belongs_to :job
|
|
|
|
has_many :ideal_jobs, class_name: "Job", foreign_key: :ideal_reference_id
|
|
has_many :agents_posts_authors, through: :person
|
|
|
|
class << self; attr_accessor :make_comments; end
|
|
self.make_comments = false
|
|
|
|
before_destroy :make_comments
|
|
|
|
def make_comments
|
|
if self.class.make_comments
|
|
person.update comments: "Reference destroyed"
|
|
end
|
|
end
|
|
end
|
|
|
|
class BadReference < ActiveRecord::Base
|
|
self.table_name = "references"
|
|
default_scope { where(favourite: false) }
|
|
end
|