상표, 모델 및 장비의 세 가지 모델이 있습니다. 브랜드 임베디드 모델, 모델 임베디드 장비. OSX everithing에 대한 개발에서 잘 작동하지만, EC2 Ubuntu 10.04 장비의 생산에서 모든 유효성 검사를 통과하고, 작성 및 저장 방법에 대해 진실을 말하며, "장비가 성공적으로 생성되었습니다"라고 출력하지만 db에는 추가되지 않습니다.몽고이 (Mongoid)의 제작 과정에서의 이상한 행동 : 레코드를 저장했지만 데이터베이스에 나타나지 않았 음
ruby-1.9.2-p180 :002 > b = Brand.create!(:title => "Volvo", :logo_file_name => "some_logo.png")
=> #<Brand _id: 4da29833b177070722000002, _type: nil, _id: BSON::ObjectId('4da29833b177070722000002'), title: "Volvo", logo_file_name: "some_logo.png", logo_content_type: nil, logo_file_size: nil, logo_updated_at: nil, active: true>
ruby-1.9.2-p180 :007 > m = b.models.create!(:title => "740")
=> #<Model _id: 4da29893b177070722000004, _type: nil, _id: BSON::ObjectId('4da29893b177070722000004'), title: "740", active: true>
ruby-1.9.2-p180 :024 > e = m.equipment.create!(:title => "1.6 Turbo", :start => 1987, :stop => 1993)
=> #<Equipment _id: 4da29a42b177070722000006, _type: nil, _id: BSON::ObjectId('4da29a42b177070722000006'), title: "1.6 Turbo", start: 1987, stop: 1993, acive: true, image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil>
ruby-1.9.2-p180 :025 > bb = Brand.last
=> #<Brand _id: 4da29833b177070722000002, _type: nil, _id: BSON::ObjectId('4da29833b177070722000002'), title: "Volvo", logo_file_name: "some_logo.png", logo_content_type: nil, logo_file_size: nil, logo_updated_at: nil, active: true>
ruby-1.9.2-p180 :026 > mm = bb.models.last
=> #<Model _id: 4da29893b177070722000004, _type: nil, _id: BSON::ObjectId('4da29893b177070722000004'), title: "740", active: true>
ruby-1.9.2-p180 :027 > ee = mm.equipment.last
=> nil
ruby-1.9.2-p180 :032 > mm.equipment
=> []
ruby-1.9.2-p180 :033 > e = m.equipment.new
=> #<Equipment _id: 4da29b15b177070722000008, _type: nil, _id: BSON::ObjectId('4da29b15b177070722000008'), title: nil, start: nil, stop: nil, acive: true, image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil>
ruby-1.9.2-p180 :034 > e.title = "1.8 SLE"
=> "1.8 SLE"
ruby-1.9.2-p180 :035 > e.start = 1988
=> 1988
ruby-1.9.2-p180 :036 > e.stop = 1994
=> 1994
ruby-1.9.2-p180 :037 > e.save!
=> true
ruby-1.9.2-p180 :038 > bb = Brand.last
=> #<Brand _id: 4da29833b177070722000002, _type: nil, _id: BSON::ObjectId('4da29833b177070722000002'), title: "Volvo", logo_file_name: "some_logo.png", logo_content_type: nil, logo_file_size: nil, logo_updated_at: nil, active: true>
ruby-1.9.2-p180 :040 > mm = bb.models.last
=> #<Model _id: 4da29893b177070722000004, _type: nil, _id: BSON::ObjectId('4da29893b177070722000004'), title: "740", active: true>
ruby-1.9.2-p180 :041 > ee = mm.equipment.last
=> nil
왜 이런 일이 발생할 수 있습니까?
글쎄, 콘솔에서 everithing 여전히 (같은 제목으로 다른 하나를 만들려면, 비록 내가 아직도 데이터베이스에서 찾을 수 없지만 생성하고 심지어 알리는) 동일하지만, 웹 인터페이스에서 나는 'Mongo :: OperationFailure (: Modifier spec은 이미 비 객체를 나타내는 이름을 가진 캡슐화 객체의 존재를 의미하거나 다른 $ set 절에서 참조됩니다.) app/controllers /equipment_controller.rb:51:in'create ' ' –
구성했습니다. 어떻게 든 mongod의 오래된 버전을 가지고 있습니다 - 1.2.2, 그래서 1.8.1로 업데이트해야하고 모든 것이 잘 작동합니다. 고맙습니다! –