[Rails] Re: Best Practices question regarding views & controllers

Cody Skidmore
Fri, 03 Mar 2006 15:45:20 -0000

As a rule, code in the view should only concern itself with rendering
the data.  Think about the code and ask yourself what the purpose of the
code is.  If its point is to render the model, it should be fine putting
it in the template.

If it manipulates the model in any way, take it out.  In MVC, the
application stack''s visibility is downward only with each layer only
knowing about the one immeadiately below it.  Think about it this way:

  View
    |
    V
Controller
    |
    V
  Model
    |
    V
Data Store

This might be a bit simplistic, but the idea is the view should not see
the model or the data store.  It should only see the controller.
Furthermore, the none of the layers should see levels above them at all,
making it strictly top-down visible.

--
Posted via http://www.ruby-forum.com/.