Sha256: 99fa9aafd900f2098823ad21ae3f27b19b05a86d02b4e9696fa477ce519d45e6
Contents?: true
Size: 928 Bytes
Versions: 8
Compression:
Stored size: 928 Bytes
Contents
require_relative "associative" module Administrate module Field class HasOne < Associative 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 def nested_form @nested_form ||= Administrate::Page::Form.new( resolver.dashboard_class.new, data || resolver.resource_class.new, ) end private def resolver @resolver ||= Administrate::ResourceResolver.new("admin/#{associated_class_name}") end end end end
Version data entries
8 entries across 8 versions & 2 rubygems