Advertisement
Guest User

shw.html.erb

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