Rails 2.0 里视图应该怎样写?
views/products/index.html.erb:
[code]
<%= render :partial => @products %>
[/code]
views/products/show.html.erb:
[code]
<%= render :partial => @product %>
[/code]
_product.html.erb:
[code]
<% div_for product do %>
<h2><%= link_to h(product.name), product %></h2>
...
<% end %>
[/code]
new.html.erb & edit.html.erb:
[code]
<% form_for @product do |f| %>
...
<% end %>
[/code]
views/products/index.html.erb:
[code]
<%= render :partial => @products %>
[/code]
views/products/show.html.erb:
[code]
<%= render :partial => @product %>
[/code]
_product.html.erb:
[code]
<% div_for product do %>
<h2><%= link_to h(product.name), product %></h2>
...
<% end %>
[/code]
new.html.erb & edit.html.erb:
[code]
<% form_for @product do |f| %>
...
<% end %>
[/code]
本文介绍Rails 2.0中视图文件的编写方式,包括index、show、new及edit页面的典型代码示例。通过具体实例展示了如何使用render方法渲染部分模板,以及如何使用form_for构建表单。
174

被折叠的 条评论
为什么被折叠?



