Skip to content

Instantly share code, notes, and snippets.

@fj
Created November 2, 2010 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fj/660258 to your computer and use it in GitHub Desktop.
Save fj/660258 to your computer and use it in GitHub Desktop.
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.find(:all).count
=> 1
ruby-1.8.7-p299 > Vehicle.where(:horsepower => 300).first
=> #<Vehicle _id: 4cd07637aca25f5746000001, top_speed_mph: "180", horsepower: "300">
ruby-1.8.7-p299 > Vehicle.where(:horsepower.gt => 299).first
=> #<Vehicle _id: 4cd07637aca25f5746000001, top_speed_mph: "180", horsepower: "300">
ruby-1.8.7-p299 > Vehicle.where(:horsepower.gt => 299, :top_speed_mph.ne => "xyz").first
=> #<Vehicle _id: 4cd07637aca25f5746000001, top_speed_mph: "180", horsepower: "300">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment