Skip to content

Instantly share code, notes, and snippets.

@jgarber623
Created August 18, 2010 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgarber623/535097 to your computer and use it in GitHub Desktop.
Save jgarber623/535097 to your computer and use it in GitHub Desktop.
An example of using layouts with partials in Rails
<form action="/path/to/some/action" method="post">
<ul id="rating-list">
<li class="average" style="width: 50px;"><span class="alt">2.5</span></li>
<%- (1..5).each do |score| -%>
<li class="rate-<%= score %>"><button type="submit" name="score" value="<%= score %>"><%= score %></button></li>
<%- end -%>
</ul>
</form>
<div id="rating">
<h2>Average Rating <span>(100)</span></h2>
<%= yield %>
</div>
<div class="article hentry">
<div class="header">
<h1 class="entry-title"><%= h( @article.title ) %></h1>
<ul class="entry-meta">
<li class="vcard">By <%= h( @article.author ) %></li>
<li class="pubdate">Added: <abbr class="published updated" title="...">...</abbr></li>
</ul>
</div>
<div class="entry-content">
<%= @article.body %>
</div>
</div>
<%#= render :partial => 'rating_form' %>
<%= render :partial => 'rating_form', :layout => 'rating_widget' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment