Fixed up new post form
added a cancel button
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user