Skip to content

Commit

Permalink
親flowの削除
Browse files Browse the repository at this point in the history
  • Loading branch information
masayaomoto committed Nov 18, 2020
1 parent 47ed9f0 commit d56c90d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/controllers/flows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ def update
redirect_to root_path
end

def destroy
@issue = Issue.find(params[:id])
@issue.children.each do |child|
child.article.destroy
end
@issue.article.destroy
redirect_to root_path
end

private

def issue_params
Expand Down
7 changes: 7 additions & 0 deletions app/javascript/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
v-bind:issue_id = "issue.id"
></parentul>
</div>
<p class="link">
<a v-bind:href="'/flows/' + issue.id + '/edit'" v-if="isShow == issue.id" >編集</a>
<a v-bind:href="'/flows/' + issue.id " v-if="isShow == issue.id" data-method="delete" data-confirm="削除しますか?【注意】この先のフローも削除されます" >削除</a>
</p>
</li>
<li class="child">
<a href="/flows/new" >追加</a>
Expand Down Expand Up @@ -184,6 +187,10 @@ export default {
font-size: 0.8em;
}
}
.link {
display: flex;
justify-content: space-around;
}
a {
text-decoration: none;
color: white;
Expand Down
3 changes: 3 additions & 0 deletions app/javascript/ul.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
v-bind:issue_id = "issue.id"
></parentul>
</div>
<p class="link">
<a v-bind:href="'/flows/' + issue.id + '/edit'" v-if="isShow == issue.id" >編集</a>
<a v-bind:href="'/flows/' + issue.id " v-if="isShow == issue.id" data-method="delete" data-confirm="削除しますか?【注意】この先のフローも削除されます" >削除</a>
</p>
</li>
<li class="child" >
<a v-bind:href="'/flows/new?parent_id=' + this.issue_id">追加</a>
Expand Down
2 changes: 1 addition & 1 deletion app/models/article.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Article < ApplicationRecord
has_many :issues
has_many :issues, dependent: :destroy
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
end
end
root to: "flows#index"
resources :flows, only: [:new, :create, :edit, :update]
resources :flows, only: [:new, :create, :edit, :update, :destroy]
end

0 comments on commit d56c90d

Please sign in to comment.