Skip to content

Commit

Permalink
Minor changes for comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
xmonkey committed Dec 4, 2012
1 parent f2d8a89 commit 88a75ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/controllers/comments_controller.rb
@@ -1,7 +1,11 @@
class CommentsController < ApplicationController class CommentsController < ApplicationController
def create def create
@post = Post.find(params[:post_id]) @post = Post.find(params[:post_id])
@post.comments.create params[:comment] @comment = @post.comments.create(params[:comment])
redirect_to @post if @comment.save
redirect_to @post
else
redirect_to @post, notice: 'Failed to add new comment.'
end
end end
end end
4 changes: 2 additions & 2 deletions app/views/posts/show.html.erb
Expand Up @@ -6,6 +6,6 @@
<% end %> <% end %>
</ul> </ul>
<%= form_for @post.comments.new, :url => post_comments_path(@post) do |f| %> <%= form_for @post.comments.new, :url => post_comments_path(@post) do |f| %>
<%= f.text_area :content, :size => "60x12" %> <%= f.text_area :content, :size => "60x2" %>
<%= f.submit "Create" %> <%= f.submit "Add comment" %>
<% end %> <% end %>

0 comments on commit 88a75ef

Please sign in to comment.