lib/avo/base_resource.rb in avo-1.23.0 vs lib/avo/base_resource.rb in avo-1.24.0

- old
+ new

@@ -34,10 +34,11 @@ class_attribute :grid_loader class_attribute :visible_on_sidebar, default: true class_attribute :unscoped_queries_on_index, default: false class_attribute :resolve_query_scope class_attribute :resolve_find_scope + class_attribute :ordering class << self def grid(&block) grid_collector = GridCollector.new grid_collector.instance_eval(&block) @@ -78,10 +79,16 @@ end def authorization Avo::Services::AuthorizationService.new Avo::App.current_user end + + def order_actions + return {} if ordering.blank? + + ordering.dig(:actions) || {} + end end def initialize unless self.class.model_class.present? self.class.model_class = model_class.base_class @@ -133,9 +140,10 @@ if reflection.present? # regular non-polymorphic association # we're matching the reflection inverse_of foriegn key with the field's foreign_key if field.is_a?(Avo::Fields::BelongsToField) if field.respond_to?(:foreign_key) && + reflection.inverse_of.present? && reflection.inverse_of.foreign_key == field.foreign_key is_valid = false end # polymorphic association