diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 643fc9c..3324564 100755 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -2,6 +2,8 @@ class ForumsController < ApplicationController load_and_authorize_resource :category load_and_authorize_resource :forum, :through => :category, :shallow => true + before_filter :check_for_cancel + def create if @forum.save flash[:notice] = "Forum was successfully created." @@ -24,4 +26,10 @@ class ForumsController < ApplicationController redirect_to forums_url end end -end \ No newline at end of file + + def check_for_cancel + if params[:commit] == 'cancel' + redirect_to @forum.nil? ? forum_path(@forum) : forums_path + end + end +end diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index a3949fa..c5e49e3 100755 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -8,51 +8,23 @@ <% if @forum.errors.any? %> <% flash.now[:error] = @forum.errors.full_messages.join(', and ') %> <% end %> -