Fixed up new post form

added a cancel button
This commit is contained in:
2013-01-21 19:10:48 -05:00
parent c75da12d94
commit 1887288f5b
7 changed files with 32 additions and 38 deletions

View File

@@ -1,7 +1,9 @@
class PostsController < ApplicationController
load_and_authorize_resource :topic
load_and_authorize_resource :post, :through => :topic, :shallow => true
before_filter :check_for_cancel#, :only[:create, :update]
def new
if params[:quote]
quote_post = Post.find(params[:quote])
@@ -12,6 +14,7 @@ class PostsController < ApplicationController
end
def create
check_for_cancel
@post.user ||= current_user
if @post.save
flash[:notice] = "Post was successfully created."
@@ -42,4 +45,10 @@ class PostsController < ApplicationController
end
end
def check_for_cancel
if params[:commit] == 'cancel'
redirect_to topic_path(@post.topic)
end
end
end