Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h1>Listing posts</h1>
- <% if user_signed_in? %>
- <div class="field">
- <%= link_to 'Create a New Post', new_post_path, :class => "btn btn-success btn-sm" %>
- </div>
- <% end %>
- <% @posts.each do |post| %>
- <div class="post thumbnail">
- <h3><%= post.name %></h3>
- <div><h5>edit by <%= post.post_user_name %></h5></div>
- <div><%= (post.descriptopm).html_safe %></div>
- <% if user_signed_in? %>
- <div class="bottom-bottoms">
- <%= link_to 'Display', post, :class => "btn btn-info btn-xs" %>
- <%= link_to 'Edit', edit_post_path(post), :class => "btn btn-info btn-xs" %>
- <%= link_to 'Delete', post, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn btn-info btn-xs" %>
- </div>
- <% end %>
- <h3>Comments</h3>
- <% post.comments.each do |comment| %>
- <div>
- <p><strong><%= comment.user_name %></strong> : <%= (comment.body).html_safe %></p>
- </div>
- <% end %>
- <%= bootstrap_form_for(@comment) do |f| %>
- <% if @comment.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
- <ul>
- <% @comment.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
- <% if user_signed_in? %>
- <div class="field">
- <%= f.text_field :user_name, value: current_user.username, :disabled => true %>
- </div>
- <div class="field">
- <%= f.text_area :body %>
- </div>
- <%= f.hidden_field :post_id, value: post.id %>
- <div class="actions">
- <%= f.submit %>
- </div>
- <% end %>
- <% end %>
- </div>
- <% end %>
- <div class="field">
- <%= f.text_field :post_user_name, value: current_user.username, :disabled => true, label: "Your Name" %>
- </div>
- def post_params
- params.require(:post).permit(:name, :post_user_name, :descriptopm)
- end
- def comment_params
- params.require(:comment).permit(:user_name, :body, :post_id)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement