module ActiveRecord::AttributeMethods

def attribute_present?(attr_name)

task.attribute_present?(:is_done) # => true
task.attribute_present?(:title) # => true
task.is_done = true
task.title = 'Buy milk'
task.attribute_present?(:is_done) # => true
task.attribute_present?(:title) # => false
task = Task.new(title: '', is_done: false)

end
class Task < ActiveRecord::Base

Note that it always returns +true+ with boolean attributes.
to objects that respond to empty?, most notably Strings). Otherwise, +false+.
database load and is neither +nil+ nor empty? (the latter only applies
Returns +true+ if the specified +attribute+ has been set by the user or by a
def attribute_present?(attr_name)
  attr_name = attr_name.to_s
  attr_name = self.class.attribute_aliases[attr_name] || attr_name
  value = _read_attribute(attr_name)
  !value.nil? && !(value.respond_to?(:empty?) && value.empty?)
end