Advertisement
Guest User

show.html.erb

a guest
Jun 13th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.77 KB | None | 0 0
  1. <h2><%= @post.title %></h2>
  2. <p><%= @post.body %></p>
  3.  
  4. <hr>
  5. <%= link_to "Edit", edit_post_path(@post), :class => 'btn btn-default' %>
  6. <%= link_to "Delete", post_path(@post), method: :delete,
  7.     data: {confirm: 'Are you sure?'},
  8.     :class => 'btn btn-danger' %>
  9.  
  10. <hr>
  11. <h3>Comments</h3>
  12. <% @post.comments.each do |comment| %>
  13.     <div class="well">
  14.         <p><strong><%= comment.username %></strong>: <%= comment.body %></p>
  15.     </div>
  16. <% end %>
  17.  
  18. <h3>Add Comment</h3>
  19. <%= form_for([@post, @post.comments.build]) do |f| %>
  20.     <p>
  21.         <%= f.label :username %><br>
  22.         <%= f.text_field :username, class: 'form-control' %>
  23.     </p>
  24.  
  25.     <p>
  26.         <%= f.label :body %><br>
  27.         <%= f.text_field :body, class: "form-control" %>       
  28.     </p>
  29.  
  30.     <p>
  31.         <%= f.submit class: 'form-control' %>
  32.     </p>
  33. <% end %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement