Best Practice for Timeliness?


#1

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?


#2

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.


#3

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.


#4

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