Gavin Morrice wrote: > 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]
Instance variables (@current_user) don't survive from request to request, so a lookup will be done for every request (in other words, from one page to the next). You could save these objects in your session and if you store sessions in memcached, things will speed up and no queries to the db will be needed. To speed up things, caching is a good thing. There are loads of tutorials about this and it caveats. -- Posted via http://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 -~----------~----~----~----~------~----~------~--~---