Module: ArelHelpers::JoinAssociation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/arel-helpers/join_association.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.join_association(table, association, join_type = Arel::Nodes::InnerJoin, options = {}, &block) ⇒ Object
activerecord uses JoinDependency to automagically generate inner join statements for any type of association (belongs_to, has_many, and has_and_belongs_to_many).
Class Method Details
.join_association(table, association, join_type = Arel::Nodes::InnerJoin, options = {}, &block) ⇒ Object
activerecord uses JoinDependency to automagically generate inner join statements for any type of association (belongs_to, has_many, and has_and_belongs_to_many). For example, for HABTM associations, two join statements are required. This method encapsulates that functionality and yields an intermediate object for chaining. It also allows you to use an outer join instead of the default inner via the join_type arg.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/arel-helpers/join_association.rb', line 20 def join_association(table, association, join_type = Arel::Nodes::InnerJoin, = {}, &block) if version >= '6.1.0' join_association_6_1_0(table, association, join_type, , &block) elsif version >= '6.0.0' join_association_6_0_0(table, association, join_type, , &block) elsif version >= '5.2.1' join_association_5_2_1(table, association, join_type, , &block) elsif version >= '5.2.0' join_association_5_2(table, association, join_type, , &block) elsif version >= '5.0.0' join_association_5_0(table, association, join_type, , &block) elsif version >= '4.2.0' join_association_4_2(table, association, join_type, , &block) elsif version >= '4.1.0' join_association_4_1(table, association, join_type, , &block) else join_association_3_1(table, association, join_type, , &block) end end |