Essentail Rails Design Pattern

Write Good Rails Code

超過 2.5 頁的 View

場景

#TODO

常用的 html 使用 partial 整理

(全站 HEADER)

1
2
3
4
5
6
7
8
9
10
11
12
<div id="header">

  <div class="group">
    <%= render :partial => "common/user_navigation"  %>
    <%= render :partial => "common/header" %>
  </div>

  <%= render :partial => "common/network" %>
  <%= render :partial => "common/man_navigation" %>
  <aside><%= ads_in_layout_top %></aside>

</div>

重複用到的 html 使用 partial 整理

(文章列表)

1
2
3
4
5
6
<article class="articles">

  <%= render :partial => "posts/s_post", :collection => @new_posts, :as => :post  %>
  <%= render :partial => "posts/apost", :collection => @advertise_posts :as => :post  %>

</article>

Comments