Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
destroy competition form in separate partial
Browse files Browse the repository at this point in the history
  • Loading branch information
norydev committed Aug 13, 2016
1 parent 3397971 commit d16768f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions app/policies/competition_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def apply?
end

def destroy?
# record.id && user && record.author == user && record.users.none?
true
record.id && user && record.author == user && record.users.none?
end
end
12 changes: 12 additions & 0 deletions app/views/competitions/_destroy_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if policy(competition).destroy? %>
<div class="panel panel-danger marged-mini">
<div class="panel-heading">
<strong><%= t('competitions.show.destroy.panel') %></strong>
</div>
<div class="panel-body">
<p><strong><%= t('competitions.show.destroy.title') %></strong></p>
<%= link_to t('competitions.show.destroy.title'), competition_path(competition), method: 'delete', class: "btn btn-danger pull-right" %>
<p><%= t('competitions.show.destroy.text') %></p>
</div>
</div>
<% end %>
13 changes: 0 additions & 13 deletions app/views/competitions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,3 @@

<%= f.button :submit, class: "btn btn-primary" %> <%= link_to t('cancel'), :back, class: "btn" %>
<% end %>
<% if policy(competition).destroy? %>
<div class="panel panel-danger marged-mini">
<div class="panel-heading">
<strong><%= t('competitions.show.destroy.panel') %></strong>
</div>
<div class="panel-body">
<p><strong><%= t('competitions.show.destroy.title') %></strong></p>
<%= link_to t('competitions.show.destroy.title'), competition_path(competition), method: 'delete', class: "btn btn-danger pull-right" %>
<p><%= t('competitions.show.destroy.text') %></p>
</div>
</div>
<% end %>
1 change: 1 addition & 0 deletions app/views/competitions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<h3><%= t('.title') %></h3>

<%= render 'form', competition: @form %>
<%= render 'destroy_form', competition: @competition %>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/competitions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
</div>
<div role="tabpanel" class="tab-pane" id="settings">
<%= render 'form', competition: @form %>
<%= render 'destroy_form', competition: @competition %>
</div>
<% end %>
</div>
Expand Down

0 comments on commit d16768f

Please sign in to comment.