Hi,
Is it possible to do a left outer join in Rails4. This is my model and I am trying to write a scope which will do a left outer join of users with the message, comments and likes tables and then group by id to get total count.
So the final result set would be cuuser.*, message_count, likes_count and comments_count. Any idea how this can be accomplished? Thanks in Advance!
class Cuuser < ActiveRecord::Base
has_and_belongs_to_many :groups
has_many :messages
has_many :comments
has_many :likes
validates :username, format: { without: /\s/ }
scope :superusers, -> { joins(:comments, :likes).
select('[cuusers.id](http://cuusers.id)').
group('[cuusers.id](http://cuusers.id)').
having('count([comments.id](http://comments.id)) + count([likes.id](http://likes.id)) > 2')}
end
Thanks,
Ganesh