-
-
Save tpitale/660264 to your computer and use it in GitHub Desktop.
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
ruby-1.8.7-p299 > class Vehicle | |
ruby-1.8.7-p299 ?> include Mongoid::Document | |
ruby-1.8.7-p299 ?> field :horsepower | |
ruby-1.8.7-p299 ?> field :top_speed_mph | |
ruby-1.8.7-p299 ?> end | |
=> nil | |
ruby-1.8.7-p299 > Vehicle.new(:horsepower => 300, :top_speed_mph => 180).save | |
=> true | |
ruby-1.8.7-p299 > Vehicle.new(:horsepower => 350, :top_speed_mph => 185).save | |
=> true | |
ruby-1.8.7-p299 > Vehicle.find(:all).count | |
=> 2 | |
ruby-1.8.7-p299 > Vehicle.where(:horsepower.gt => 299, :top_speed_mph.ne => 180) | |
=> [#<Vehicle _id: 4cd07637aca25f5746000001, top_speed_mph: "180", horsepower: "300">,#<Vehicle _id: 4cd07637aca25f5746000002, top_speed_mph: "185", horsepower: "350">] | |
# I was not expecting to get back any records with the top_speed_mph of 180 | |
# The first condition always works in another case in which the conditions are reversed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment