lib/avo/fields/belongs_to_field.rb in avo-3.10.1 vs lib/avo/fields/belongs_to_field.rb in avo-3.10.2

- old
+ new

@@ -279,11 +279,15 @@ else value end end - def can_create? - @can_create + # field :user, as: :belongs_to, can_create: true + # Only can create when: + # - `can_create: true` option is present + # - target resource's policy allow creation (UserPolicy in this example) + def can_create?(final_target_resource = target_resource) + @can_create && final_target_resource.authorization.authorize_action(:create, raise_exception: false) end def form_field_label "#{id}_id" end