今日任務
今日總結
- Action view
- render
使用<%= render "layout/menu" %> 來調用局部視圖
<% render partial: "product" %>
在 _product.html.erb 中,就可使用本地變量 product 表示 @product
object 選項可以直接指定要在局部視圖中使用的對象。
<%= render partial: "product",object: @item %>
- 鏈接靜態資源
<%= stylesheet_link_tag "application", media: "all" %>
# 這個方法可以使用stylesheet下的樣式
<%= javascript_include_tag "application" %>
# 可以鏈接靜態JavaScript資源