这是日志
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 >
当我尝试保存一些对象时,我得到了以上响应。以下是我的Mongoid和mongo的 gem 版本,我认为这是mongoid.yml的问题,但不确定,因为我的yml非常好
使用bson(1.3.1)
使用bson_ext(1.3.1)
使用mongo(1.3.1)
安装Mongoid(2.1.9)
蒙古扁 bean
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:[email protected]:10029/appid
如果您发现任何错误,请告诉我
最佳答案
尝试:
u.save(:validate=> false)
关于ruby-on-rails - NoMethodError : undefined method `[]' for false:FalseClass,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7166382/