Created
August 16, 2012 03:21
-
-
Save telagraphic/3366227 to your computer and use it in GitHub Desktop.
Nested Resources
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
<section class="comments"> | |
<h2>Post A Comment</h2> | |
<%= form_for([@post, @comment]) do |comment| %> | |
<%= comment.label :email %><br/> | |
<%= comment.text_field :email %><br/> | |
<%= comment.label :body %><br/> | |
<%= comment.text_area :body, :size => "60x12" %><br/> | |
<%= comment.submit "Shout out" %> | |
<% end %> | |
</section> |
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
class CommentsController < ApplicationController | |
before_filter :get_post | |
def get_post | |
@post = Post.find(params[:post_id]) | |
end | |
def new | |
@comment = @post.comments.build | |
end | |
end |
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
<%= link_to "Back", posts_path %> | |
<article class="post"> | |
<h2><%= @post.title %><h2> | |
<h3><%= @post.created_at %></h3> | |
<section class=""> | |
<iframe width="560" height="315" src="<%= @post.youtube %>" frameborder="0" allowfullscreen></iframe> | |
</section> | |
<p class=""><%= @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 %> | |
<%= link_to "Back", posts_path %> | |
<%= render "comments/comment_form" %> | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment