Sha256: 18de6cfd55a8e95d30d7279c6881970d2a795988ff3a3d8d9402453a1c8c851e
Contents?: true
Size: 928 Bytes
Versions: 7
Compression:
Stored size: 928 Bytes
Contents
require_relative "associative" module Administrate module Field class HasOne < Associative def nested_form @nested_form ||= Administrate::Page::Form.new( resolver.dashboard_class.new, data || resolver.resource_class.new, ) end def self.permitted_attribute(attr, options = nil) associated_class_name = if options options.fetch(:class_name, attr.to_s.singularize.camelcase) else attr end related_dashboard_attributes = Administrate::ResourceResolver.new("admin/#{associated_class_name}"). dashboard_class.new.permitted_attributes + [:id] { "#{attr}_attributes": related_dashboard_attributes } end private def resolver @resolver ||= Administrate::ResourceResolver.new("admin/#{associated_class_name}") end end end end
Version data entries
7 entries across 7 versions & 2 rubygems