moving page_ids to ids

This commit is contained in:
Torsten 2022-12-11 16:44:19 +02:00
parent dc4124a03d
commit fd86f0531c
7 changed files with 12 additions and 12 deletions

View File

@ -12,7 +12,7 @@ module Merged
message = "Must enter name" if name.blank?
if( message.nil?)
@page = Page.build_new(name)
redirect_to new_page_section_url(@page.name) , notice: "Page was successfully created."
redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created."
else
@pages = Page.all.values
flash.now.alert = message

View File

@ -34,7 +34,7 @@ module Merged
def destroy
@section.destroy()
@section.page.save
redirect_to page_sections_url(@section.page.name) , notice: "Section #{@section.index} removed"
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.index} removed"
end
def set_image
@ -66,7 +66,7 @@ module Merged
@section.move_down
end
@section.save
redirect_to page_sections_url(@section.page.name)
redirect_to page_sections_url(@section.page.id)
end
def update

View File

@ -10,7 +10,7 @@ module Merged
fields :name , :content , :size , :updated_at
def sections
Section.where(page_id: name).order(index: :asc)
Section.where(page_id: id).order(index: :asc)
end
def self.check_name(name)

View File

@ -5,7 +5,7 @@
.flex.items-center.justify-center.flex-1
.max-w-xl.px-4.py-8.mx-auto.text-center
%h1.text-3xl.font-bold.tracking-tight.text-gray-900
Page #{link_to @section.page.name, page_sections_url(@section.page.name), class: "underline"}
Page #{link_to @section.page.name, page_sections_url(@section.page.id), class: "underline"}
.flex.items-center.justify-center.flex-1
%h3.text-xl.font-bold.tracking-tight.text-gray-900
Cards for

View File

@ -21,7 +21,7 @@
- @pages.each do |merged_page|
%tr
%td.whitespace-nowrap.px-4.py-2.text-gray-700
= link_to merged_page.name , page_sections_path(merged_page.name)
= link_to merged_page.name , page_sections_path(merged_page.id)
%td.whitespace-nowrap.px-4.py-2.text-gray-700
= merged_page.sections.length
%td.whitespace-nowrap.px-4.py-2.text-gray-700
@ -30,9 +30,9 @@
= distance_of_time_in_words_to_now(merged_page.updated_at)
%td.whitespace-nowrap.px-4.py-2
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
= link_to 'Sections', page_sections_path(merged_page.name)
= link_to 'Sections', page_sections_path(merged_page.id)
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
= link_to 'Edit', edit_page_path(merged_page.name)
= link_to 'Edit', edit_page_path(merged_page.id)
.grid.grid-cols-3.gap-2.m-8
.relative.block.border.border-gray-100

View File

@ -15,7 +15,7 @@
= blue_button( "Up" , section_move_url(section.id , dir: :up) )
= blue_button( "Down" , section_move_url(section.id , dir: :down) )
= yellow_button("Edit" , section_path(section.id) )
= green_button( "Copy" , new_page_section_url(@page.name, template: section.template) )
= green_button( "Copy" , new_page_section_url(@page.id, template: section.template) )
= form_tag( section_url(section.id) , {method: :delete } ) do
=submit_button( "Delete" , true)
.relative.block.border.border-gray-100.p-4
@ -49,8 +49,8 @@
.grid.grid-cols-2.gap-2.m-8
.relative.block
%p
= green_button( "New Section" , new_page_section_url(@page.name) )
= green_button( "New Section" , new_page_section_url(@page.id) )
.relative.block
%p
= form_tag( page_url(@page.name) , {method: :delete } ) do
= form_tag( page_url(@page.id) , {method: :delete } ) do
=submit_button( "Delete Page" , true)

View File

@ -18,7 +18,7 @@
%h3.mt-4.text-lg.font-bold Template #{@section.template}
= section_preview(@section , class: "w-full object-contain p-3")
= yellow_button( "Change Template" , section_select_template_url(@section.id))
= green_button( "New Section" , new_page_section_url(@section.page.name , template: @section.template) )
= green_button( "New Section" , new_page_section_url(@section.page.id , template: @section.template) )
.relative.block.border.border-gray-100
= section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do