lib/avo/fields/belongs_to_field.rb in avo-3.6.4 vs lib/avo/fields/belongs_to_field.rb in avo-3.8.0
- old
+ new
@@ -239,16 +239,18 @@
return nil
end
else
reflection_key = polymorphic_as || id
- if @record._reflections[reflection_key.to_s].klass.present?
- get_resource_by_model_class(@record._reflections[reflection_key.to_s].klass.to_s)
- elsif @record._reflections[reflection_key.to_s].options[:class_name].present?
- get_resource_by_model_class(@record._reflections[reflection_key.to_s].options[:class_name])
+ reflection_object = @record._reflections.with_indifferent_access[reflection_key]
+
+ if reflection_object.klass.present?
+ get_resource_by_model_class(reflection_object.klass.to_s)
+ elsif reflection_object.options[:class_name].present?
+ get_resource_by_model_class(reflection_object.options[:class_name])
else
- App.get_resource_by_name reflection_key.to_s
+ App.get_resource_by_name reflection_key
end
end
end
def get_record
@@ -261,9 +263,17 @@
super
end
def can_create?
@can_create
+ end
+
+ def form_field_label
+ "#{id}_id"
+ end
+
+ def polymorphic_form_field_label
+ "#{id}_type"
end
private
def get_model_class(record)