diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 40c8ba0..12afe73 100755 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -1,6 +1,8 @@ class TopicsController < ApplicationController load_and_authorize_resource :forum load_and_authorize_resource :topic, :through => :forum, :shallow => true + + before_filter :check_for_cancel def show @topic.hit! if @topic @@ -43,5 +45,11 @@ class TopicsController < ApplicationController redirect_to forum_url(@topic.forum) end end + + def check_for_cancel + if params[:commit] == 'cancel' + redirect_to @topic.new_record? ? @forum : @topic + end + end end diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb index 09ce4de..d38d341 100755 --- a/app/views/topics/_form.html.erb +++ b/app/views/topics/_form.html.erb @@ -6,28 +6,21 @@