어제이 작업을 멋지게 처리했으며 변경 작업을 수행 한 결과 어떻게 부러 졌는지 알 수 없습니다. 나는 그것이 어딘가에 오타라고 확신하지만 나는 그것을 볼 수 없다.Mongoid의 참조 _ONE에 중첩 속성이 저장되지 않았습니다.
양식의 중첩 된 모델에 대한 변경 사항은 전혀 저장되지 않으며 개발 로그는 통과하는 속성을 보여줍니다. 그리고 그들은 올바른 형식으로 표시되지만 전혀 업데이트되지 않습니다. (formtastic에 내가 여기에 간단한 양식을 사용하고 있지만, 대부분의 경우 매우 유사한 동작)
# app/models/user.rb
class User
include Mongoid::Document
include Mongoid::Timestamps
field :first_name, :type => String
field :last_name, :type => String
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
references_one :biography
accepts_nested_attributes_for :biography
#--snip---
end
# app/models/biography.rb
class Biography
include Mongoid::Document
include Mongoid::Timestamps
field :content, :type => String
field :role, :type => String
field :is_crew, :type => Boolean
referenced_in :user
end
그리고 마지막으로 내 양식 :
나는과 같이Biography
을 references_one
User
모델이
<%= simple_form_for [:manage, @user], :html => {:multipart => true}, :position => :left do |f| %>
<h2>Login details</h2>
<%= f.input :email, :input_html => {:class => "text"} %>
<%= f.input :first_name, :input_html => {:class => "text"} %>
<%= f.input :last_name, :input_html => {:class => "text"} %>
<div class="biography">
<h2>Biography</h2>
<%= f.simple_fields_for :biography do |biography_form| %>
<%= biography_form.input :role, :input_html => {:class => "text"} %>
<%= biography_form.input :content, :as => :text, :input_html => {:class => "textarea"} %>
<%= biography_form.input :is_crew, :as => :boolean %>
<%- end -%>
</div>
<%= f.submit "Save user", :class => "submit mid" %>
<% end %>
그리고 내 개발 로그에서 일부 출력, 답변이 거짓말을하고, 난 그냥 캔트가 볼 까봐 :
Started POST "/manage/users/john-doe" for 127.0.0.1 at Wed Dec 15 11:42:09 +1100 2010
Processing by Manage::UsersController#update as HTML
Parameters: {"commit"=>"Save user", "authenticity_token"=>"44QlHsbKb8Pm91wnxWJa8Y0QsUXDzp/3rVpfs3G1Inc=", "utf8"=>"✓", "id"=>"john-doe", "user"=>{"biography_attributes"=>{"is_crew"=>"0", "role"=>"Tenor", "id"=>"4d080de56a4f1dfe7700000e", "content"=>"John was born on the 1st of January, 1970."}, "last_name"=>"Doe", "first_name"=>"Johnathan", "email"=>"[email protected]"}}
the_idea_of_north_development['users'].find({:_id=>BSON::ObjectId('4d06e6036a4f1dcb1b000001')}, {}).limit(-1)
the_idea_of_north_development['users'].find({:slug=>"john-doe"}, {}).limit(-1)
the_idea_of_north_development['biographies'].find({"user_id"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, {}).limit(-1)
the_idea_of_north_development['$cmd'].find({"count"=>"users", "query"=>{:_id=>{"$ne"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, :email=>/^[email protected]\.com\.au$/i}, "fields"=>nil}, {}).limit(-1)
the_idea_of_north_development['users'].find({"slug"=>"johnathan-doe"}, {})
MONGODB the_idea_of_north_development['users'].update({"_id"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, {"$set"=>{"slug"=>"johnathan-doe", "updated_at"=>Wed Dec 15 00:42:09 UTC 2010, "first_name"=>"Johnathan"}})
Redirected to http://lvh.me:3000/manage/users
Completed 302 Found in 17ms
User
모델의 모든 변경 사항이 잘 업데이트되지만 Biography
으로 변경되면 저장되지 않습니다. hive-mind, 당신은 나의 유일한 희망입니다!
문제 # 357이 mongoid 2.0 rc 1에서 해결 될 것 같습니다. 이번 1 월에 예정되어 있습니다. 후속 조치 주셔서 감사합니다. – wwilkins
나는이 문제를 조금 짚어 봤는데 당신이 옳을 거라고 생각합니다. 패치가 일을 분류한다면이 대답을 받아 들일 것입니다. 젠체하는 사람. – theTRON
RC1로 업데이트되었지만 문제 # 357이 아직 수정되지 않은 것으로 보이며 참조 된 모델에 새로운 문제가 있음을 알 수 있습니다. 베타 -20으로 돌아 가야했습니다. – theTRON