Class: IronTrail::Association
- Inherits:
-
ActiveRecord::Associations::HasManyAssociation
- Object
- ActiveRecord::Associations::HasManyAssociation
- IronTrail::Association
- Defined in:
- lib/iron_trail/association.rb
Instance Method Summary collapse
Instance Method Details
#association_scope ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/iron_trail/association.rb', line 5 def association_scope klass = self.klass reflection = self.reflection scope = klass.unscoped owner = self.owner chain = [::ActiveRecord::Reflection::RuntimeReflection.new(reflection, self)] foreign_key = reflection.join_foreign_key pk_value = owner._read_attribute(foreign_key) pk_table = owner.class.arel_table scope.where!('rec_id' => pk_value, 'rec_table' => pk_table.name) scope end |
#find_target ⇒ Object
22 23 24 |
# File 'lib/iron_trail/association.rb', line 22 def find_target scope.to_a end |