Cleaned up new topic form
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -6,28 +6,21 @@
|
||||
<div class="module_header"><%= action_name.humanize %> Topic</div>
|
||||
<div class="module_subheader smaller"></div>
|
||||
<div class="module_body">
|
||||
<div class="fieldset">
|
||||
<span class="label indent smaller">
|
||||
<%= f.label :title %><br />
|
||||
<small>(Required)</small>
|
||||
</span>
|
||||
<span class="input indent smaller"><%= f.text_field :title, :size => 75 %></span>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<%= f.label :title %>
|
||||
<span class="input indent smaller"><%= f.text_field :title, :style => "width:98%" %></span>
|
||||
<div class="clear"></div>
|
||||
<% unless @topic.id %>
|
||||
<div class="fieldset">
|
||||
<span class="label indent smaller">
|
||||
<%= f.label :body %><br />
|
||||
<small>(Required)</small>
|
||||
</span>
|
||||
<span class="input indent smaller"><%= f.text_area :body, :cols => 60, :rows => 15 %></span>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<%= f.label :body %>
|
||||
<span class="input indent smaller"><%= f.text_area :body, :style => "width:98%", :rows => 15 %></span>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="module_footer">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user