DonutWorks / Ari

0 stars 0 forks source link

where(condition).exists? 를 exists?(condition)으로 바꾸기 #324

Closed shaynekang closed 9 years ago

shaynekang commented 9 years ago

레일즈 모델에는 exists?라는 메소드가 있습니다. 인자로 받은 조건에 해당하는 모델이 존재하는지 체크해주는 메소드입니다. 가령

def responsed_to?(notice)
  responses.where(notice: notice).exists?
end

def responsed_to?(notice)
  responses.exists?(notice: notice)
end

로 바꿀 수 있습니다. 다른 코드도 살펴본 뒤, exist? 함수를 사용할 수 있는 곳은 수정하면 좋겠습니다. ㅎㅎㅎ