Re: Slow performance

Justin Mazzi
Sat, 31 Mar 2007 00:23:00 -0000

Nik wrote:
> May I add just one more thing I saw in the command prompt when loading
> the page using the fast and slow method:
>
> For the FAST method: it show only a few new lines
> For the slow method: it shows a few thousand lines of these:
> Rendered /recipe/_i <0.00100>
> ...
>
> Does that help?

instead of doing

page.replace_html ''targetdiv'', :partial =>
''i'', :collection =>
Recipes.find(:all)

try something like this:

@recipes= Recipes.find(:all)
page.replace_html ''targetdiv'', :partial =>
''i''

then in your i partial, do

for var in @recipes
  html that loops here
end

The issue is that ruby has to make 5000 template renders. If you do the
loop in the view, its just 1 render.

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