Rails 方法 - 返回布林值

Rails 模型中的任何方法都可以返回布林值。

簡單的方法 -

  ##this method return ActiveRecord::Relation
  def check_if_user_profile_is_complete
    User.includes( :profile_pictures,:address,:contact_detail).where("user.id = ?",self)
  end

再次簡單的方法返回布林值 -

  ##this method return Boolean(NOTE THE !! signs before result)
  def check_if_user_profile_is_complete
    !!User.includes( :profile_pictures,:address,:contact_detail).where("user.id = ?",self)
  end

所以,相同的方法現在將返回布林值而不是其他任何東西:)。