Module: ActiveRecord::DynamicMatchers::FindByDeprecationWarning

Included in:
FindBy, FindByBang
Defined in:
lib/active_record/deprecated_finders/dynamic_matchers.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_record/deprecated_finders/dynamic_matchers.rb', line 33

def body
  <<-CODE
    if block_given?
      ActiveSupport::Deprecation.warn("Calling find_by or find_by! methods with a block is deprecated with no replacement.")
    end

    unless options.empty?
      ActiveSupport::Deprecation.warn(
        "Calling find_by or find_by! methods with options is deprecated. " \
        "Build a scope instead, e.g. User.where('age > 21').find_by_name('Jon')."
      )
    end

    #{super}
  CODE
end