Commit 408fffc0 authored by John Noel's avatar John Noel

Added Posts index page

parent 86e5a595
class PostsController < ApplicationController class PostsController < ApplicationController
def index def index
@posts = Post.all
end end
def show def show
......
<h1>Posts#index</h1> <h1>Posts</h1>
<p>Find me in app/views/posts/index.html.erb</p>
<div>
<%= link_to "Create new post", new_post_path, class: "btn btn-primary" %>
</div>
<br>
<% if @posts.empty? %>
<small>
No posts have been created.
</small>
<% else %>
<table class="table">
<thead>
<th>Title</th>
<th>Content</th>
<th colspan="3"></th>
</thead>
<tbody>
<% @posts.each do |post| %>
<tr>
<td>
<%= post.title %>
</td>
<td>
<%= post.content %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment