
“Partial Templates” (aka. “partials”) is a way for breaking down the rendering process into more simplified and manageable chunks. Think of it as a placeholder for a piece of the webpage that is stored in another file. The partial command calls for the other file to be rendered in the response.
Calling a partial is coded as follows:
|
|
This command would call for _menu.html.erb to be rendered where the above code is inserted. All partial view files are named with a leading underscore _XXX to distinguish partials from regular view files.
During the Intermedia Homework assignment, the view/index.html.erb file used a partial to render the collection of the groups model, displaying information for each member of the group:
|
|
With the partial code:
|
|
This displays a table showing each group, which works similarly as the <% @groups.each do |f| %> function.




近期评论