Module: ActiveScaffold::Tableless::Tableless

Defined in:
lib/active_scaffold/tableless.rb

Instance Method Summary collapse

Instance Method Details

#skip_statement_cache?(scope) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_scaffold/tableless.rb', line 35

def skip_statement_cache?(scope)
  klass < ActiveScaffold::Tableless ? true : super
end

#target_scopeObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_scaffold/tableless.rb', line 39

def target_scope
  super.tap do |scope|
    if klass < ActiveScaffold::Tableless
      class << scope; include RelationExtension; end
      assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
      if assoc_conditions&.present?
        scope.conditions.concat(assoc_conditions.map { |c| c.is_a?(Hash) ? c[klass.table_name] || c : c })
      end
    end
  end
end