Rails methods - returning boolean values

suggest change

A model method can return a boolean. A relation does not.

This returns an ActiveRecord::Relation. The relation object is always truthy, even when no row matches. !! does not turn it into “any records existed”. The table is users, not user, and self is not an id.

def matching_profile
  User.includes(:profile_pictures, :address, :contact_detail).where(id: id)
end

Ask the database if a row exists:

def profile_complete?
  User.where(id: id).exists?
end

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents