Với Rails 3, sau khi nâng cấp từ Mongoid 2.x lên Mongoid 3.x, thiết lập Heroku + MongoHQ của tôi ngừng hoạt động. Điều thú vị là, sự phát triển của tôi & các khung kiểm tra và toàn bộ bộ thử nghiệm của tôi chỉ chạy tốt.Mongoid 3 + Heroku (MongoHQ) gây ra Xe máy :: Lỗi :: OperationFailure
tôi nghi ngờ vấn đề là với tập tin mongoid.yml của tôi, nhưng tôi đã cố gắng tìm kiếm các tài liệu, google & stackoverflow, và sử dụng tất cả các định dạng đề nghị, bao gồm này: heroku mongohq and mongoid Mongo::ConnectionFailure hoặc thực sự này: https://gist.github.com/2900804
CẬP NHẬT ngày 16 tháng 7: Đây là cách tập mongoid.yml tôi trông, sau khi thử nhiều thứ + sau những gì Jason từ MongoHQ gợi ý:
development:
sessions:
default:
database: development
hosts:
- localhost:27017
test:
sessions:
default:
database: test
hosts:
- localhost:27017
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URL'] %>
options:
skip_version_check: true
safe: true
(sự hiểu biết của tôi, nó là về cơ bản giống như một trong các liên kết ở trên, ngoại trừ việc nó sử dụng uri; Tôi đã thử cách khác, tách MONGOHQ_URL thành các trường riêng biệt nữa, nhưng nó không giúp được)
Tôi đã thử cài đặt mongoid là 3.0.0rc và để trống phiên bản trong Gemfile của tôi. Sử dụng phiên bản github không thành công do chứng chỉ HTTPS hoặc thứ gì đó, vì vậy tôi không bận tâm thử nhiều lần.
gì điều khiển hành động nói đây là:
Moped::Errors::OperationFailure in Home#index
Showing /app/app/views/home/index.html.haml where line #2 raised:
The operation: #<Moped::Protocol::Command
@length=68
@request_id=4
@response_to=0
@op_code=2004
@flags=[:slave_ok]
@full_collection_name=".$cmd"
@skip=0
@limit=-1
@selector={:count=>:posts, :query=>{}}
@fields=nil>
failed with error "db assertion failure"
và khi tôi chạy
heroku run console
.. Tôi có được điều này:
irb(main):052:0> Location.create!
NoMethodError: undefined method `[]' for nil:NilClass
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:74:in `block in command'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:522:in `[]'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:522:in `block (3 levels) in flush'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:521:in `map'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:521:in `block (2 levels) in flush'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:113:in `ensure_connected'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:517:in `block in flush'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:532:in `logging'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:516:in `flush'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:505:in `process'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:70:in `command'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/node.rb:356:in `refresh'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/cluster.rb:101:in `block in refresh'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/cluster.rb:114:in `each'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/cluster.rb:114:in `refresh'
from /app/vendor/bundle/ruby/1.9.1/gems/moped-1.1.1/lib/moped/cluster.rb:67:in `nodes'
... 15 levels...
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/callbacks.rb:98:in `run_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/persistence/insertion.rb:23:in `prepare'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/persistence/operations/insert.rb:26:in `persist'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/persistence.rb:50:in `insert'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/persistence.rb:251:in `block in create!'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/threaded/lifecycle.rb:173:in `_creating'
from /app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.1/lib/mongoid/persistence.rb:249:in `create!'
from (irb):52
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):053:0>
Tôi nghĩ rằng tôi đã googled tất cả mọi thứ , chạy qua nhiều vấn đề goidub mongoid, đọc tài liệu nhiều lần ... và tôi đang hết ý tưởng ở đây.
Mọi điều cần lưu ý tôi nên thử tiếp theo?
CẬP NHẬT 16 tháng 7: đây là những gì Heroku nói khi tôi git chủ push Heroku (Sau khi thực hiện những gì Jason từ MongoHQ gợi ý):
git push heroku master
Counting objects: 7, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 372 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.pre
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.3.6)
Using activesupport (3.2.6)
Using builder (3.0.0)
# ... shortened this #
Using libv8 (3.3.10.4)
Using moped (1.1.2)
Using origin (1.0.4)
Using mongoid (3.0.0.rc)
Using omniauth (1.1.0)
Using quimby (0.4.5)
Using bundler (1.2.0.pre)
Using rails (3.2.6)
Using therubyracer (0.10.1)
Using thin (1.3.1)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Asset precompilation completed (31.24s)
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 18.7MB
-----> Launching... done, v92
http://xxxxx.herokuapp.com deployed to Heroku
To [email protected]:xxxxx.git
b2d97xy..7b0aczy master -> master
UPDATE 2 16 tháng 7: đã là Jason & MrKurt nói (đầu tiên quên chạy gói cập nhật mongoid, nhưng điều đó không giúp được gì). Bây giờ lỗi thay đổi, mặc dù:
NoMethodError in Home#index
Showing /app/app/views/home/index.html.haml where line #2 raised:
undefined method `[]' for nil:NilClass
Extracted source (around line #2):
1: %h1 Most recent posts
2: - if @posts.length > 0
Tôi làm việc tại MongoHQ, nếu bạn có thể gửi email hỗ trợ @ mongohq.com chúng tôi có thể cung cấp cho bạn hỗ trợ trực tiếp về điều này. --edit-- Dường như Mongoid không gửi tên cơ sở dữ liệu + bộ sưu tập thông qua đúng (hãy kiểm tra thuộc tính "full_collection_name"). Phiên bản Mongoid 3x nào? RC trước đó có một số vấn đề với cấu hình cơ sở dữ liệu URI. – MrKurt
1) Làm cách nào để kiểm tra thuộc tính "full_collection_name"? 2) Vì một lý do nào đó tôi đã chạy 3.0.0.rc mà không biết –- nó nghĩ rằng tôi đã xóa nó rồi. Tuy nhiên, điều đó không thay đổi tình hình. – herb
Tôi có lỗi này, phương pháp quá undefined '[] 'cho nil: NilClass và nó không nói nơi nó đến từ AT ALL –