Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created August 16, 2012 18:19
Show Gist options
  • Save telagraphic/3372349 to your computer and use it in GitHub Desktop.
Save telagraphic/3372349 to your computer and use it in GitHub Desktop.
Comment.count
<% 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>
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