cards and section get proper belongs_to associations

This commit is contained in:
2022-12-17 14:28:01 +02:00
parent cdb9a3466a
commit 609ca0d57d
5 changed files with 45 additions and 2 deletions

View File

@ -1,4 +1,4 @@
require "mini_magick"
require "mini_magick"
module Merged
class Image < ActiveYaml::Base

View File

@ -103,5 +103,12 @@ module Merged
Section.reload
end
def self.transform
Section.all.each do |card|
card.image = card.image_old
card.save
end
end
end
end

View File

@ -8,6 +8,8 @@ module Merged
set_root_path Rails.root #ouside engines not necessary
include ActiveHash::Associations
belongs_to :image , class_name: "Merged::Image"
fields :options , :updated_at , :updated_by
def has_option?(option)
@ -61,7 +63,7 @@ module Merged
template_style.fields.collect{|f| f.to_sym}
end
def image
def image_old
Image.find_by_name(self.image_name)
end
end