这是日志
umair-2:game-minion umairejaz$rails c /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.7/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr/local/bin in PATH,mode 040777 /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /usr/local/bin in PATH,mode 040777 Loading development environment (Rails 3.0.7) ruby-1.9.2-p290 :001 > u = User.new => #<User _id: 4e53f783713931a571000001,_type: nil,username: nil,first_name: nil,last_name: nil,email: nil,password: nil,password_salt: nil,password_hash: nil,profile_picture: nil,facebook_id: nil,facebook_enabled: nil,facebook_access_token: nil,twitter_id: nil,twitter_enabled: nil,twitter_access_token: nil,twitter_access_secret: nil,points: nil,remember_token: nil,remember_token_expires_at: nil> ruby-1.9.2-p290 :002 > u.username = "umair" => "umair" ruby-1.9.2-p290 :003 > u.save(false) NoMethodError: undefined method `[]' for false:FalseClass from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence/operations.rb:143:in `validating?' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence/insertion.rb:23:in `block in prepare' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence/insertion.rb:22:in `tap' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence/insertion.rb:22:in `prepare' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence/operations/insert.rb:26:in `persist' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence.rb:44:in `insert' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/mongoid-2.1.9/lib/mongoid/persistence.rb:142:in `upsert' from (irb):3 from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start' from /Users/umairejaz/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' ruby-1.9.2-p290 :004 >
当我尝试保存一些对象时,我得到了以上响应. Follwoing是我的mongoid和mongo的宝石版本,我认为它是mongoid.yml的一个问题,但不确定,因为我的yml是完美的
使用bson(1.3.1)
使用bson_ext(1.3.1)
使用mongo(1.3.1)
安装mongoid(2.1.9)
mongoid.yml
defaults: &defaults host: localhost development: <<: *defaults database: gm_development test: <<: *defaults database: gm_test production: host: <%= ENV['MONGOID_HOST'] %> port: <%= ENV['MONGOID_PORT'] %> username: <%= ENV['MONGOID_USERNAME'] %> password: <%= ENV['MONGOID_PASSWORD'] %> database: <%= ENV['MONGOID_DATABASE'] %> uri: mongodb://username:password@staff.mongohq.com:10029/appid
如果您发现任何问题,请告诉我
解决方法
尝试:
u.save(:validate=> false)