好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

partial render for rails

partial render for rails

3.4 Using Partials

Partial templates – usually just called “partials” – are another device for breaking apart the rendering process into more manageable chunks. With a partial, you can move the code for rendering a particular piece of a response to its own file.

3.4.1 Naming Partials

To render a partial as part of a view, you use the  render  method within the view, and include the :partial  option:

<%= render "menu" %>

This will render a file named  _menu.html.erb  at that point within the view being rendered. Note the leading underscore character: partials are named with a leading underscore to distinguish them from regular views, even though they are referred to without the underscore. This holds true even when you’re pulling in a partial from another folder:

<%= render "shared/menu" %>

That code will pull in the partial from  app/views/shared/_menu.html.erb .

 

http://guides.rubyonrails.org/layouts_and_rendering.html

查看更多关于partial render for rails的详细内容...

  阅读:45次

上一篇: ror小记

下一篇:wincvs应用笔记