From dd34326777d150fa889bbf058227b7a6a9fd9ca3 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Tue, 22 Jan 2013 10:49:55 -0500 Subject: [PATCH] Cleaned up new topic form --- app/controllers/topics_controller.rb | 8 ++++++++ app/views/topics/_form.html.erb | 27 ++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) 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 @@
<%= action_name.humanize %> Topic
-
- - <%= f.label :title %>
- (Required) -
- <%= f.text_field :title, :size => 75 %> -
-
+ <%= f.label :title %> + <%= f.text_field :title, :style => "width:98%" %> +
<% unless @topic.id %> -
- - <%= f.label :body %>
- (Required) -
- <%= f.text_area :body, :cols => 60, :rows => 15 %> -
-
+ <%= f.label :body %> + <%= f.text_area :body, :style => "width:98%", :rows => 15 %> +
<% end %>