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)


27
28
29
# File 'lib/active_scaffold/tableless.rb', line 27

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

#target_scopeObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_scaffold/tableless.rb', line 31

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