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 %> -
- - <%= f.label :category_id %>
- (Required) -
- - <%= f.collection_select :category_id, Category.all, :id, :title %> - -
-
-
- - <%= f.label :title %>
- (Required) -
- <%= f.text_field :title, :size => 75 %> -
-
-
- - <%= f.label :description %>
- (Required) -
- <%= f.text_area :description, :cols => 60, :rows => 5 %> -
-
-
- - <%= f.label :position %> - - <%= f.text_field :position %> -
-
-
- - - <%= f.check_box :state %> - <%= f.label :state %> - -
-
+ <%= f.label :category_id %> + <%= f.collection_select :category_id, Category.all, :id, :title %> + <%= f.label :title %> + <%= f.text_field :title, :style => "width:98%" %> + <%= f.label :description %>
+ <%= f.text_area :description, :style => "width:98%", :rows => 5 %> + <%= f.label :position %> + <%= f.text_field :position %> +
+ <%= f.label :state %> + <%= f.check_box :state %>