Created
February 15, 2011 04:30
-
-
Save alsemyonov/827095 to your computer and use it in GitHub Desktop.
Mongoid STI scopes exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongoid' | |
connection = Mongo::Connection.new | |
Mongoid.config.database = Mongo::DB.new('example', connection) | |
class A | |
include Mongoid::Document | |
field :foo, :type => Integer | |
scope :asc_by_foo, asc(:foo) | |
end | |
class B < A | |
field :bar, :type => Integer | |
scope :asc_by_bar, asc(:bar) | |
end | |
B.asc_by_foo # => NoMethodError: undefined method `conditions' for nil:NilClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment