Skip to content

Instantly share code, notes, and snippets.

@alsemyonov
Created February 15, 2011 04:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alsemyonov/827095 to your computer and use it in GitHub Desktop.
Save alsemyonov/827095 to your computer and use it in GitHub Desktop.
Mongoid STI scopes exception
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