Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds some missing validations to Comment model. Fixes some redirect/f…

…lashes issues. All thanks to tests
  • Loading branch information...
commit ffb18626d1be9e776e9ccf7e3dfc1ab964389a68 1 parent 2890b49
Javier Fonseca V authored
View
2  app/controllers/comments_controller.rb
@@ -6,7 +6,7 @@ def create
if @comment.save
redirect_to post_path(@post), :notice => "Your comment was submitted. Thank you"
else
- redirect_to post_path(@post), :error => "Your comment couldn't be submitted"
+ redirect_to post_path(@post), :alert => "Your comment couldn't be submitted"
end
end
end
View
4 app/controllers/posts_controller.rb
@@ -21,7 +21,7 @@ def update
@post = Post.find(params[:id])
if @post.update_attributes(params[:post])
- redirect_to posts_path, :notice => "Your post was edited succesfully"
+ redirect_to post_path(@post), :notice => "Your post was edited succesfully"
else
flash[:error] = "There were some errors editing your post"
render action: "edit"
@@ -38,7 +38,7 @@ def create
@post.user = current_user
if @post.save
- redirect_to posts_path, :notice => "Your post was created succesfully"
+ redirect_to post_path(@post), :notice => "Your post was created succesfully"
else
flash[:error] = "There were some errors creating your post"
render action: "new"
View
2  app/models/comment.rb
@@ -1,3 +1,5 @@
class Comment < ActiveRecord::Base
belongs_to :post
+
+ validates_presence_of :nickname, :message, :post_id
end
Please sign in to comment.
Something went wrong with that request. Please try again.