Q:

:joins | change behavior inner join to left join

I have two tables 'users' and 'lms_users'
class LmsUser
    belongs_to :user
end

class User
    has_one :lms_user
end

When I write User.all(:joins => :lms_user) it joins tables with Inner join. 
I want a Left join.  How can change this behavior? ( I don't want to use SQL commands, only Ruby syntax for this.) 
How can I handle this? 

A:

You can pull off LEFT JOIN without SQL, using includes, but only if you specify additional constraint (or merely an order clause) which involves a column from joined table(s).  So,
User.includes(:lms_user).all

won't generate LEFT JOIN (but two separate queries instead), but
User.includes(:lms_user).where(:lms_user => {:role => 'admin'}).all

would. 
More about this on

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html (see eager loading section)
http://ruby.ryanbigg.com/post/1468788928/left-outer-join-with-arel

