image delete

This commit is contained in:
Torsten 2022-12-19 21:15:46 +02:00
parent a1ca7f6b29
commit f61ce40e71
3 changed files with 17 additions and 8 deletions

View File

@ -16,6 +16,12 @@ module Merged
} }
end end
def destroy
@image = Image.find(params[:id])
@image.destroy
redirect_to :images , nootice: "Image #{@image.name} deleted"
end
def show def show
@image = Image.find(params[:id]) @image = Image.find(params[:id])
@sections = Section.where(image_id: params[:id].to_i) @sections = Section.where(image_id: params[:id].to_i)

View File

@ -32,21 +32,24 @@
%div %div
-@sections.each do |section| -@sections.each do |section|
%p %p
= section.header = link_to section.header , section_url(section)
on Page on Page
= section.page.name = link_to section.page.name , page_sections_url(section.page)
%div %div
-@cards.each do |card| -@cards.each do |card|
%p %p
= card.header = link_to card.header , section_cards_url(card.section)
on Page on Page
= card.section.page.name = link_to card.section.page.name , page_sections_url(card.section.page)
-else -else
.grid.grid-cols-2.m-20 .grid.grid-cols-2.m-20
%p Not used, you may delete %div
%p %p Not used, you may delete
Delete button %div
%p
= form_tag( image_url(@image.id) , {method: :delete } ) do
=submit_button( "Delete" , true)
.m-20 .m-20
= image_tag(@image.asset_name) = image_tag(@image.asset_name)

View File

@ -1,7 +1,7 @@
- content_for( :merged_menu ) do - content_for( :merged_menu ) do
.text-xl.font-bold.text-gray-900 .text-xl.font-bold.text-gray-900
Page Page
= @page.name = link_to @page.name , page_url(@page)
.text-xl.text-gray-900 .text-xl.text-gray-900
=link_to "View live" , "/#{@page.name}" , target: @page.name =link_to "View live" , "/#{@page.name}" , target: @page.name