/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
partial a _preview in posts/index.html.erb ------------- way_1 code @ index.html.erb <%= render :partial => "posts/preview", :collection => @posts, :as => :post %> code @ _preview.html.erb <% div_for post do %> <h2><%= link_to_unless_current h(post.title), post %></h2> <%= truncate(post.body, :length => 300) %> <stule class="read_more"><%= link_to_unless_current h("read more"), post %></style> <br /><br /> <% end %> ------------- way_2 code @ index.html.erb <%= render :partial => "preview" %> code @ _preview.html.erb <% for post in @posts do %> <% div_for post do %> <h2><%= link_to_unless_current h(post.title), post %></h2> <%= truncate(post.body, :length => 300) %> <stule class="read_more"><%= link_to_unless_current h("read more"), post %></style> <br /><br /> <% end %> <% end %> -------------
Comments
