Skip to content

Instantly share code, notes, and snippets.

@rbarazi
Created April 9, 2010 02:26
Show Gist options
  • Save rbarazi/360814 to your computer and use it in GitHub Desktop.
Save rbarazi/360814 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 11-7 – Updated article partial in app/views/articles/_article.html.erb and other views
<%= div_for article do %>
<h3>
<%= link_to article.title, article %>
<% if article.owned_by? current_user %>
<span class='actions'>
<%= link_to t('general.edit'), edit_article_path(article) %>
<%= link_to t('general.delete'), article, :confirm => t('general.are_you_sure'), :method => :delete %>
</span>
<% end %>
</h3>
<%= simple_format raw(article.body) %>
<% end %>
<%= div_for comment do %>
<h3>
<%= comment.name %> &lt;<%= comment.email %>&gt; said:
<% if @article.owned_by? current_user %>
<span class='actions'>
<%= link_to t('general.delete'), [@article, comment], :confirm => t('general.are_you_sure'), :method => :delete, :remote => true %>
</span>
<% end %>
</h3>
<%= comment.body %>
<% end %>
<%= form_tag(notify_friend_article_path(@article), :id => 'notify_friend_form', :style => 'display:none') do %>
<div class="field">
<%= label_tag :name, t('general.your_name') %><br />
<%= text_field_tag :name %>
</div>
<div class="field">
<%= label_tag :email, t('general.your_friend_email') %><br />
<%= text_field_tag :email %>
</div>
<div class="actions">
<%= submit_tag t('general.send_email') %>
<%= t('general.or') %>
<%= link_to t('general.cancel'), '#', :onclick => "$('#notify_friend_form').slideUp()" %>
</div>
<% end %>
<h1><%= t('articles.editing_article') %></h1>
<%= render 'form' %>
<%= link_to t('general.show'), @article %> |
<%= link_to t('general.back'), articles_path %>
<h1><%= t('articles.listing_articles') %></h1>
<div id="articles">
<%= render @articles %>
</div>
<h1><%= t('users.new_user') %></h1>
<%= render 'form' %>
<%= link_to t('general.back'), articles_path %>
<%= render @article %>
<%= link_to t('general.email_a_friend'), '#', :onclick => "$('#notify_friend_form').slideDown()" %>
<%= render 'notify_friend' %>
<h3><%= t('comments.comments') %></h3>
<div id="comments">
<%= render @article.comments %>
</div>
<%= link_to t('comments.new_comment'), new_article_comment_path(@article, :format => :js), :remote => true, :id => 'new_comment_link' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment