# Best Practice for Timeliness?

**URL:** <https://www.ruby-forum.com/t/best-practice-for-timeliness/153525>\
**Category:** Rails\
**Created:** [November 18, 2008, 11:42am UTC](https://www.ruby-forum.com/t/best-practice-for-timeliness/153525 "2008-11-18T11:42:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blacknight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@blacknight](https://www.ruby-forum.com/u/blacknight)\
**Post date:** [November 18, 2008, 11:42am UTC](https://www.ruby-forum.com/t/best-practice-for-timeliness/153525/1 "2008-11-18T11:42:02Z")

</div>

Hey, I want to highlight rows in an index view based on their  
timeliness. That is, is a record late, due soon, etc. Is it a better  
practice to put the business logic in the helper or model?

---

<div class="post-metadata">

**Author:** ![blacknight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@blacknight](https://www.ruby-forum.com/u/blacknight)\
**Post date:** [November 18, 2008, 12:17pm UTC](https://www.ruby-forum.com/t/best-practice-for-timeliness/153525/2 "2008-11-18T12:17:13Z")

</div>

While business logic should in fact go into the model  
(if possible, otherwise controller, never in the view or helpers),  
this isn’t exactly business logic. It’s just a question about  
how to display some given data and that goes into  
the helper or view.

---

<div class="post-metadata">

**Author:** ![blacknight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@blacknight](https://www.ruby-forum.com/u/blacknight)\
**Post date:** [November 18, 2008, 12:21pm UTC](https://www.ruby-forum.com/t/best-practice-for-timeliness/153525/3 "2008-11-18T12:21:20Z")

</div>

that depends: generally spoken, business logic should be put into  
models. but if you only want to change format, coloring, etc. thats a  
typical helper-function.

---

<div class="post-metadata">

**Author:** ![blacknight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@blacknight](https://www.ruby-forum.com/u/blacknight)\
**Post date:** [November 18, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/best-practice-for-timeliness/153525/4 "2008-11-18T19:19:44Z")

</div>

> Hey, I want to highlight rows in an index view based on their  
> timeliness. That is, is a record late, due soon, etc. Is it a better  
> practice to put the business logic in the helper or model?

Both. Add methods to your model such as is\_late?, due\_soon?, etc  
(returning true/false). Then in your helper method use those methods  
to determine what style to apply to the row.

-philip
