Forum: Ruby on Rails Is accessing models in views bad?

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.
CSN (Guest)
on 2006-01-10 23:49
(Received via mailing list)
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
CSN


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This topic is locked and can not be replied to.