class User < ActiveRecord::Base
has_many :messages
scope :without_messages, -> { where.not(id: Message.select(:user_id).uniq.compact) }
end
class Message < ActiveRecord::Base
belongs_to :user
end
Last active
March 16, 2016 15:45
-
-
Save francois-blanchard/e7e957648f8dbc3f7437 to your computer and use it in GitHub Desktop.
Scope for get objects with no association
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment