Module: ActiveScaffold::Tableless::Tableless

Defined in:
lib/active_scaffold/tableless.rb

Instance Method Summary collapse

Instance Method Details

#association_scopeObject



65
66
67
68
# File 'lib/active_scaffold/tableless.rb', line 65

def association_scope
  @association_scope ||= AssociationScope.scope(self, klass.connection) if klass < ActiveScaffold::Tableless
  super
end

#skip_statement_cache?(scope) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/active_scaffold/tableless.rb', line 61

def skip_statement_cache?
  klass < ActiveScaffold::Tableless ? true : super
end

#target_scopeObject



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/active_scaffold/tableless.rb', line 75

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