RailsCasts Pro episodes are now free!
Learn more or hide this
I should have mentioned, not all of the tips work best for this specific example. I would probably stop after the first tip. But I wanted to give you some more ideas for solving this problem which may work well in your situation.
<% for article in @articles %> <% render :layout => 'article', :object => article do %> <p><%=h article.description %></p> <p><%= link_to "Read More...", article %></p> <% end %> <% end %>
<% stylesheet 'article' %> <% render :layout => 'article', :object => @article do %> <%= simple_format(h(@article.content)) %> <% end %>
<div class="article"> <h2><%= link_to_unless_current h(article.name), article %></h2> <div class="info"> by <%= article.author %> on <%= article.created_at.to_s(:long) %> <span class="comments"> <%= link_to pluralize(article.comments.size, 'Comment'), article %> </span> </div> <div class="content"> <%= yield %> </div> </div>
<%= yield(:head) %>
def stylesheet(*args) content_for(:head) { stylesheet_link_tag(*args) } end
.article .comments_link { display: none; }