Cleaned up new topic form
This commit is contained in:
@@ -2,6 +2,8 @@ class TopicsController < ApplicationController
|
|||||||
load_and_authorize_resource :forum
|
load_and_authorize_resource :forum
|
||||||
load_and_authorize_resource :topic, :through => :forum, :shallow => true
|
load_and_authorize_resource :topic, :through => :forum, :shallow => true
|
||||||
|
|
||||||
|
before_filter :check_for_cancel
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@topic.hit! if @topic
|
@topic.hit! if @topic
|
||||||
|
|
||||||
@@ -44,4 +46,10 @@ class TopicsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_for_cancel
|
||||||
|
if params[:commit] == 'cancel'
|
||||||
|
redirect_to @topic.new_record? ? @forum : @topic
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,28 +6,21 @@
|
|||||||
<div class="module_header"><%= action_name.humanize %> Topic</div>
|
<div class="module_header"><%= action_name.humanize %> Topic</div>
|
||||||
<div class="module_subheader smaller"></div>
|
<div class="module_subheader smaller"></div>
|
||||||
<div class="module_body">
|
<div class="module_body">
|
||||||
<div class="fieldset">
|
<%= f.label :title %>
|
||||||
<span class="label indent smaller">
|
<span class="input indent smaller"><%= f.text_field :title, :style => "width:98%" %></span>
|
||||||
<%= f.label :title %><br />
|
<div class="clear"></div>
|
||||||
<small>(Required)</small>
|
|
||||||
</span>
|
|
||||||
<span class="input indent smaller"><%= f.text_field :title, :size => 75 %></span>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
<% unless @topic.id %>
|
<% unless @topic.id %>
|
||||||
<div class="fieldset">
|
<%= f.label :body %>
|
||||||
<span class="label indent smaller">
|
<span class="input indent smaller"><%= f.text_area :body, :style => "width:98%", :rows => 15 %></span>
|
||||||
<%= f.label :body %><br />
|
<div class="clear"></div>
|
||||||
<small>(Required)</small>
|
|
||||||
</span>
|
|
||||||
<span class="input indent smaller"><%= f.text_area :body, :cols => 60, :rows => 15 %></span>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="module_footer">
|
<div class="module_footer">
|
||||||
<div class="fieldset">
|
<div class="fieldset">
|
||||||
<span class="input"><%= f.submit "submit" %> or <%= link_to "cancel", @topic.new_record? ? @forum : @topic %></span>
|
<span class"input">
|
||||||
|
<%= f.submit "Submit", :class =>"btn btn-primary"%>
|
||||||
|
<%= button_tag "Cancel", :confirm => 'Are you sure? Any changes will be lost.', :class => 'btn', :type => 'submit', :name => 'commit', :value => 'cancel' %>
|
||||||
|
</span>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user