Sha256: efc09f6ce57d46d4040552660278798941efc2df79ca210200dc51ece9af588f
Contents?: true
Size: 1.02 KB
Versions: 5
Compression:
Stored size: 1.02 KB
Contents
module Avo module Fields class HasManyField < BaseField def initialize(name, **args, &block) @defaults = { updatable: false, partial_name: 'has-many-field' } @through = args[:through] super(name, **args, &block) hide_on :all show_on :show @resource = args[:resource] end def turbo_frame "#{self.class.name.demodulize.to_s.underscore}_#{id}" end def frame_url "#{Avo.configuration.root_path}/resources/#{@model.model_name.route_key}/#{@model.id}/#{id}?turbo_frame=#{turbo_frame}" end def target_resource if @model._reflections[id.to_s].klass.present? App.get_resource_by_model_name @model._reflections[id.to_s].klass.to_s elsif @model._reflections[id.to_s].options[:class_name].present? App.get_resource_by_model_name @model._reflections[id.to_s].options[:class_name] else App.get_resource_by_name id.to_s end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems