Permalink
Browse files

Minor changes for comments.

  • Loading branch information...
1 parent f2d8a89 commit 88a75eff63d0ee397d22563452d26f14c7d01c8e @xmonkey committed Dec 4, 2012
Showing with 8 additions and 4 deletions.
  1. +6 −2 app/controllers/comments_controller.rb
  2. +2 −2 app/views/posts/show.html.erb
@@ -1,7 +1,11 @@
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
- @post.comments.create params[:comment]
- redirect_to @post
+ @comment = @post.comments.create(params[:comment])
+ if @comment.save
+ redirect_to @post
+ else
+ redirect_to @post, notice: 'Failed to add new comment.'
+ end
end
end
@@ -6,6 +6,6 @@
<% end %>
</ul>
<%= form_for @post.comments.new, :url => post_comments_path(@post) do |f| %>
- <%= f.text_area :content, :size => "60x12" %>
- <%= f.submit "Create" %>
+ <%= f.text_area :content, :size => "60x2" %>
+ <%= f.submit "Add comment" %>
<% end %>

0 comments on commit 88a75ef

Please sign in to comment.