DonutWorks / Ari

0 stars 0 forks source link

Response의 scope :time은 데코레이터로 빼기 #328

Closed shaynekang closed 9 years ago

shaynekang commented 9 years ago

모델의 scope 함수는 where함수를 간결화 하는 용도로만 사용합니다. 그래서 다음의 코드는 scope가 아닌 다른 곳으로 빼는 게 좋을 것 같습니다.

scope :time, -> (notice) { find_by_notice_id(notice.id).created_at.localtime.strftime("%Y-%m-%d %T") }

제가 볼 땐 Draper를 활용해서 Response라는 Collection의 데코레이터로 활용하는게 좋을 것 같네요. 다른 코드에도 비슷한 상황이 있다면 수정하도록 합시다. ㅎㅎ