lib/avo/base_resource.rb in avo-1.21.1.pre.1 vs lib/avo/base_resource.rb in avo-1.22.0.pre.1

- old
+ new

@@ -4,11 +4,11 @@ extend FieldsCollector extend HasContext include ActionView::Helpers::UrlHelper - delegate :view_context, to: 'Avo::App' + delegate :view_context, to: "Avo::App" delegate :main_app, to: :view_context delegate :avo, to: :view_context delegate :resource_path, to: :view_context delegate :resources_path, to: :view_context @@ -19,11 +19,11 @@ class_attribute :id, default: :id class_attribute :title, default: :id class_attribute :description, default: :id class_attribute :search_query, default: nil - class_attribute :search_query_help, default: '' + class_attribute :search_query_help, default: "" class_attribute :includes, default: [] class_attribute :model_class class_attribute :translation_key class_attribute :translation_enabled class_attribute :default_view_type, default: :table @@ -58,11 +58,11 @@ end # This is the search_query scope # This should be removed and passed to the search block def scope - self.query_scope + query_scope end # This resolves the scope when doing "where" queries (not find queries) def query_scope final_scope = resolve_query_scope.present? ? resolve_query_scope.call(model_class: model_class) : model_class @@ -126,20 +126,22 @@ .select do |field| field.visible? end .select do |field| # Strip out the reflection field in index queries with a parent association. - if reflection.present? && - reflection.options.present? && - field.respond_to?(:polymorphic_as) && - field.polymorphic_as.to_s == reflection.options[:as].to_s - next - end - if field.respond_to?(:foreign_key) && - reflection.present? && - reflection.respond_to?(:foreign_key) && - reflection.foreign_key != field.foreign_key - next + if reflection.present? + if reflection.options.present? && + field.respond_to?(:polymorphic_as) && + field.polymorphic_as.to_s == reflection.options[:as].to_s + next + end + + if field.respond_to?(:foreign_key) && + reflection.respond_to?(:foreign_key) && + reflection.foreign_key != field.foreign_key && + @params[:resource_name] == field.resource.model_key + next + end end true end