lib/avo/base_resource.rb in avo-1.19.1.pre.3 vs lib/avo/base_resource.rb in avo-1.19.1.pre.4
- old
+ new
@@ -341,12 +341,13 @@
if field.type == "belongs_to"
id = field.foreign_key.to_sym
reflection = @model._reflections[@params[:via_relation]]
- if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params["via_relation_class"])
- value = @params["via_relation_class"].safe_constantize.find(@params[:via_resource_id])
+ if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class])
+ # set the value to the actual record
+ value = @params[:via_relation_class].safe_constantize.find(@params[:via_resource_id])
elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s
value = @params[:via_resource_id]
end
end
@@ -439,9 +440,9 @@
rescue
nil
end
def form_scope
- model.class.base_class.to_s.downcase
+ model.class.base_class.to_s.underscore.downcase
end
end
end