Is this type of calculation to be put in Model or Controller?

Posted by Hadi on Stack Overflow See other posts from Stack Overflow or by Hadi
Published on 2010-06-01T10:10:31Z Indexed on 2010/06/01 10:13 UTC
Read the original article Hit count: 336

Filed under:
|
|
|

i have Product and SalesOrder model (to simplify, 1 sales_order only for 1 product)

Product has_many SalesOrder SalesOrder belongs_to Product

pa = Product A #2000 so1 = SalesOrder 1 order product A #1000, date:yesterday so2 = SalesOrder 2 order product A #999, date:yesterday so3 = SalesOrder 3 order product A #1000, date:now

Based on the date, pa.find_sales_orders_that_can_be_delivered will give: SalesOrder 1 order product A #1000, date:yesterday SalesOrder 2 order product A #999, date:yesterday SalesOrder 3 order product A #1, date:now <-- the newest

The question is: is find_sales_orders_that_can_be_delivered should be in the Model? i can do it in controller.

and the general question is: what goes in Model and what goes in Controller.

Thank you

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby