Forum: Ruby on Rails Best Practice for Timeliness?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6e3d8ebb0811dfdf750edfaac6f4957f?d=identicon&s=25 Ben Wilson (Guest)
on 2008-11-18 11:42
(Received via mailing list)
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?
2d8132658d56e51f19ace1c68e48b6aa?d=identicon&s=25 Thorsten Mueller (thorsten)
on 2008-11-18 12:17
(Received via mailing list)
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.
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2008-11-18 12:21
(Received via mailing list)
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.
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2008-11-18 19:19
(Received via mailing list)
> 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
This topic is locked and can not be replied to.