我期待编写一个范围,返回所有没有特定关联的记录.
foo.rb
class Foo < ActiveRecord::Base
has_many :bars
end
Run Code Online (Sandbox Code Playgroud)
bar.rb
class Bar < ActiveRecord::Base
belongs_to :foo
end
Run Code Online (Sandbox Code Playgroud)
我希望有一个范围,可以找到所有的Foo's那不要有任何bars.很容易找到使用关联的那些joins,但我还没有找到相反的方法.