Is accessing models in views bad?

I do it because:

  1. Different retrieved records use different
    variations of the same template, and may want
    more/fewer/different queries and present them
    differently. Plus templates can display whatever they
    want and not have to rely on the controller to assign
    it data. e.g. index1.rhtml can retrieve and display
    categories, news, calendar; index2.rhtml can retrieve
    and display categories, news, users; etc. I don’t know
    of a simple way to do this in the controller.

  2. Queries inside cache blocks aren’t executed
    (right?). I don’t know of a way to do this inside a
    controller. e.g.

<% cache ‘abc’ do %>
<% for item in Stuff.find(:all, :conditions=‘abc=123’

<% end %>

Any thoughts? Thanks

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs