redirect_to :action => :index需要跳转到index这个action,然后渲染index.html.erb,额外增加了一次http请求。直接render "index", :alert => 'Your book was not found!'就把额外的这次请求给免了
render是服务器直接给你页面。
redirect_to是服务器给浏览器地址,浏览器再次请求服务器给自己的哪个地址,跳转。
render是渲染模板
redirect_to是跳转,也就是发送新的请求到某Action
版权声明:本文为qwbtc原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。