From e6effde4ffae75d4ca6e470db3404666633f2630 Mon Sep 17 00:00:00 2001 From: Torsten Date: Mon, 12 Dec 2022 18:35:18 +0200 Subject: [PATCH] fix images --- app/controllers/merged/cards_controller.rb | 4 ++-- app/controllers/merged/sections_controller.rb | 4 ++-- app/models/merged/card.rb | 3 ++- app/models/merged/page.rb | 3 ++- app/models/merged/section.rb | 5 +++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/controllers/merged/cards_controller.rb b/app/controllers/merged/cards_controller.rb index 42b88ca..ca0b9a8 100644 --- a/app/controllers/merged/cards_controller.rb +++ b/app/controllers/merged/cards_controller.rb @@ -11,9 +11,9 @@ module Merged end def set_image - @card.content["image"] = params[:image] + @card.image = params[:image] @card.save - redirect_to section_cards_url(@card.section.id) + redirect_to section_cards_url(@card.section.id) , notice: "Image selected: #{@card.image}" end def move diff --git a/app/controllers/merged/sections_controller.rb b/app/controllers/merged/sections_controller.rb index c91defe..8c771a4 100644 --- a/app/controllers/merged/sections_controller.rb +++ b/app/controllers/merged/sections_controller.rb @@ -37,9 +37,9 @@ module Merged end def set_image - @section.content["image"] = params[:image] + @section.image = params[:image] @section.save - redirect_to section_url(@section.id) + redirect_to section_url(@section.id) , notice: "Image selected: #{@section.image}" end def set_template diff --git a/app/models/merged/card.rb b/app/models/merged/card.rb index 79cb8de..7b9a343 100644 --- a/app/models/merged/card.rb +++ b/app/models/merged/card.rb @@ -7,7 +7,8 @@ module Merged include Optioned - fields :index , :section_id, :id , :text , :header, :image + fields :id , :index , :section_id + fields :text , :header, :image , :options def move_up swap_index_with(next_card) diff --git a/app/models/merged/page.rb b/app/models/merged/page.rb index fad92f7..5bbba28 100644 --- a/app/models/merged/page.rb +++ b/app/models/merged/page.rb @@ -55,13 +55,14 @@ module Merged end def save + updated_at = Time.now super Page.save_all end def self.new_page(name ) raise "only alphanumeric, not #{name}" unless check_name(name).nil? - data = { name: name.dup } + data = { name: name.dup , updated_at: Time.now } Page.new(data) end diff --git a/app/models/merged/section.rb b/app/models/merged/section.rb index e3718d1..3adf0ef 100644 --- a/app/models/merged/section.rb +++ b/app/models/merged/section.rb @@ -7,8 +7,9 @@ module Merged include Optioned - fields :name , :page_id , :index , :options - fields :template , :card_template , :id , :text , :header, :image + fields :id , :name , :page_id , :index + fields :template , :card_template + fields :header, :text , :image , :options def cards Card.where(section_id: id).order(index: :asc)