Module: LeftJoin::Adapters::ActiveRecordAdapter

Defined in:
lib/left_join/adapters/active_record_adapter.rb

Instance Method Summary collapse

Instance Method Details

#left_join(*columns) ⇒ Object

Does a left join through an association. Usage:

Book.left_join(:category)
# SELECT "books".* FROM "books"
# LEFT OUTER JOIN "categories"
# ON "books"."category_id" = "categories"."id"

It also works through association’s associations, like ‘joins` does:

Book.left_join(category: :master_category)


14
15
16
# File 'lib/left_join/adapters/active_record_adapter.rb', line 14

def left_join(*columns)
  joins(ActiveRecord::Associations::JoinDependency.new(self, columns, []))
end