Sha256: d3ed98865752d0a90cebaecf2e9bbcf5b7401cc245626695b91bf28574786ba4
Contents?: true
Size: 820 Bytes
Versions: 19
Compression:
Stored size: 820 Bytes
Contents
# frozen_string_literal: true module Tramway::Core::ExtendableFormsHelpers::MorePropertiesHelper def define_property_method(property_name) define_method property_name do model.values[property_name] if model.values end end def define_assignment_method(property) define_method "#{property[0]}=" do |value| property[1][:validates].each do |pair| make_validates property[0], pair, value end end end def define_file_property_assignment_method(property, field) define_method "#{property[0]}=" do |value| file_instance = property[1][:association_model].find_or_create_by( "#{model.class.name.underscore}_id" => model.id, "#{field.class.name.underscore}_id" => field.id ) file_instance.file = value file_instance.save! end end end
Version data entries
19 entries across 19 versions & 1 rubygems