简体   繁体   English

如何在Ruby On Rails 2.3.8中优化视图渲染?

[英]How to opitmize view rendering in Ruby On Rails 2.3.8?

I have a rails app which shows the following log for a single action 我有一个rails应用程序,它显示单个操作的以下日志

Completed in 587ms (View: 415, DB: 29) | 200 OK [http://localhost/]

its taking 415 ms to render the view layer. 它花了415毫秒来渲染视图层。 Is there any way to optimize view rendering in rails ? 有没有办法在rails中优化视图渲染? I am a beginner in ruby on rails. 我是轨道上红宝石的初学者。

I have render call like this on a page(written in HAML) that showed me the above log time. 我在一个页面(用HAML编写)上进行了这样的渲染调用,向我展示了上面的日志时间。 I want to optimize the rendering of these partials 我想优化这些部分的渲染

  - auctions.each do |auction|
    = render :partial => "/shared/vertical_item", :object => auction,:inline => true  

thanks 谢谢

A very nice way to optimize views is by using Fragment and Page Caching. 优化视图的一种非常好的方法是使用Fragment和Page Caching。 But be careful about overdoing it. 但要小心过度。

I could be confused, but i do not know what the :inline => true is supposed to do. 我可能会感到困惑,但我不知道:inline => true应该是什么。 According to me :inline is used to render inline erb without using a template, eg 根据我的说法:inline用于渲染内联erb而不使用模板,例如

  render :inline => "<%= 'hello ' + name %>", :locals => { :name => "david" }

(from the documentation ) (来自文档

So i would suggest to remove that :inline => true and see if that helps. 所以我建议删除它:inline => true ,看看是否有帮助。

Otherwise i would like to see that partial you are using. 否则我想看到你正在使用的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM