Created
June 24, 2011 10:03
-
-
Save iboard/1044531 to your computer and use it in GitHub Desktop.
default_scope doesn't work on debian
This file contains 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
# MODEL | |
class Page | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
include CoverPicture | |
#.... | |
field :is_template, :type => Boolean, :default => false | |
default_scope where(is_template: false ) | |
scope :templates, where(is_template: true ) | |
# On Mac OS X (Lion preview 3) everything works fine. | |
# On Debian it doesn't. Page.all is always empty. | |
# Versions of Ruby, Rails, Mongo, MongoID all the same on both machines. | |
# Tests | |
test "Page select should not include templates" do | |
Page.delete_all | |
template_page = Page.create(:title => 'This is a template page', :body => "I'm a template", :is_template => true) | |
standard_page = Page.create(:title => 'This is a standard page', :body => "Standard") | |
sp = Page.first | |
tp = Page.templates.first | |
assert sp.title == 'This is a standard page', 'First without param is_template should be the standard page' | |
assert tp.title == 'This is a template page', 'Using Page.templates.first should be the template page' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment