Created
August 16, 2012 18:19
-
-
Save telagraphic/3372349 to your computer and use it in GitHub Desktop.
Comment.count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if user_signed_in? %> | |
<%= link_to "New Post", new_post_path %> | |
<% end %> | |
<article class="post"> | |
<% @posts.each do |post| %> | |
<h1><%= link_to post.title, post %></h1> | |
<h4> Posted <a href="#"><July 13, 2012><%= post.created_at.strftime("%d %b. %Y") %></a> </h4> | |
<h5><%= @comments.count %></h5> | |
<section class="video"> | |
<iframe width="560" height="315" src="<%= post.youtube %>" frameborder="0" allowfullscreen></iframe> | |
</section> | |
<p><%= post.content %></p> | |
<hr> | |
<% if user_signed_in? %> | |
<%= link_to "Edit", edit_post_path(post) %> | |
<%= link_to "Destroy", post, :confirm => "Are you sure", :method => :delete %> | |
<% end %> | |
<% end %> | |
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
@posts = Post.all | |
@post = Post.find(params[:id]) | |
@comments = Comment.all | |
end | |
def show | |
@post = Post.find(params[:id]) | |
@comment = @post.comments.build #associates comments with posts | |
@comments = @post.comments.all #shows all comments for the post | |
end | |
POPS THIS ERROR: | |
Couldn't find Post without an ID | |
says "Couldn't find Post without an ID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment