Use find_or_create_*
hash = {user_id: user_id, level_id: level_id, status: UserLevelStatus::READY} UserLevelStatus.find_or_create_by_user_id_and_level_id_and_status(hash)
EDITED For your case, you should use the following
hash = {user_id: user_id, level_id: level_id} UserLevelStatus.find(:first, :conditions => hash) || UserLevelStatus.create(hash.merge({status: UserLevelStatus::READY})
Salil source share