lib/administrate/field/has_one.rb in administrate-0.12.0 vs lib/administrate/field/has_one.rb in administrate-0.13.0
- old
+ new
@@ -1,17 +1,10 @@
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
@@ -20,9 +13,16 @@
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