Skip to content

Commit

Permalink
Build a Show Page for a Post"
Browse files Browse the repository at this point in the history
  • Loading branch information
xmonkey committed Nov 28, 2012
1 parent 237d09a commit fbc7acf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/posts_controller.rb
Expand Up @@ -2,4 +2,7 @@ class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
end
7 changes: 7 additions & 0 deletions app/views/posts/show.html.erb
@@ -0,0 +1,7 @@
<h3><%= link_to @post.title, @post.url %> </h3>
<p><%= pluralize(@post.comments.count, ' comment') %> </p>
<ul>
<% @post.comments.each do |comment| %>
<li> <%= comment.content %> </li>
<% end %>
</ul>
1 change: 1 addition & 0 deletions config/routes.rb
@@ -1,4 +1,5 @@
CourseProject::Application.routes.draw do
#root to: "main#index"
root to: "posts#index"
resources :posts, :only => [:index, :show]
end

0 comments on commit fbc7acf

Please sign in to comment.