RoundOutTooSoon
RoundOutTooSoon

Reputation: 9891

Rails: leaving much code in view

I am writing a view where there is some logic involved. I could put these in a model or controller. But my question is, is it a bad practice leaving this much of logic in the view? (ruby code) Please see my code here

http://pastie.org/3440454

Upvotes: 0

Views: 186

Answers (2)

phoenixwizard
phoenixwizard

Reputation: 5209

YEs, you should put minimum code on view and maximum code in model

I love this philosophy of skinny controllers and fat models : http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model

Upvotes: 3

deefour
deefour

Reputation: 35350

Yes, it's bad practice. Something like

TestFieldDefinition.find_all_by_company_id(...)

is business logic; it belongs in the Controller, not a View. The same goes for the majority of that pastie; that much conditional logic with no rendering of content is business logic and should be moved to the controller.

Upvotes: 2

Related Questions