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)


43
44
45
# File 'lib/active_scaffold/tableless.rb', line 43

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

#target_scopeObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/active_scaffold/tableless.rb', line 47

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