読者です 読者をやめる 読者になる 読者になる

何回も調べてしまう attribute? の定義箇所

Rails Rails

ここを見ると query methods と書かれているので、 https://github.com/rails/rails/blob/master/activerecord/lib/active_record/base.rb

  # == Attribute query methods
  #
  # In addition to the basic accessors, query methods are also automatically available on the Active Record object.
  # Query methods allow you to test whether an attribute value is present.
  # Additionally, when dealing with numeric values, a query method will return false if the value is zero.
  #
  # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
  # to determine whether the user has a name:
  #
  #   user = User.new(name: "David")
  #   user.name? # => true
  #
  #   anonymous = User.new(name: "")
  #   anonymous.name? # => false

ここを見に行くとそれがある https://github.com/rails/rails/blob/master/activerecord/lib/active_record/attribute_methods/query.rb