You shouldn't be making database calls from the view.
If you're making calls for the application layout then I'd add these
to the application controller and call them with a before_filter
(anyone know a better way ?)

If the objects you are calling are the same from one page to the next
you could try using an "or equals"

so instead of always calling
@current_user = User.find session[:user_id]

you could write @current_user ||= User.find session[:user_id]

This should mean that the database call is only made if @current_user
is nil

does that help?

On Apr 20, 1:33 pm, Preethi Sivakumar <rails-mailing-l...@andreas-
s.net> wrote:
> Hi,
> This may be a silly question to ask. But as performance issues start
> popping up I had no other go other than searching for a solution.
> I've application.html.erb where i've defined the layout of my whole
> project, where i've so many db calls and everything which is a one time
> call that must happen for the whole layout.
> In the main area i've
>
>                    <%= yield %>
>
> I want only this part to be refreshed/changed whenever i go back and
> forth of the pages, but the problem is, the whole page is getting
> refreshed everytime which is consuming hell a lot of time as i'm doing
> so many db calls for the common layout.
>
> How to achieve my requirement and improve the performance?
> And if someother tips are there the improve the performance in ruby on
> rails
> Thanks in advance :)
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to