2012-09-26 2 views
1

은 내가 고치를 사용하여 중첩 된 양식 simple_form을 사용하고 mongoid has_one 관계를간단한 양식, 몽구스, has_one 저장하지 않습니까?

class Banner 
    include Mongoid::Document 
    field :url, type: String 
    has_one :asset 
    embedded_in :campaign 

    validates_presence_of :url 
end 

그리고

class Asset 
    include Mongoid::Document 
    belongs_to :user 

있습니다.

campaign[banners_attributes][0][url]:Gadf 
campaign[banners_attributes][0][asset]:506203a70fc16ce14f00000d 
campaign[banners_attributes][0][_destroy]: 
campaign[banners_attributes][0][id]:5062f1330fc16cfd6b000011 

그러나 자산이 배너에 관련되지 않습니다 : simple_form

<%= f.input :asset, :collection => @assets%> 
<%= f.input :url %> 

에 대한

정의이 포스트 액션에서 출력됩니다. 어떤 아이디어?

+0

has_one :asset, autosave: true을 시도 그래서 자산의 기록'''506203a70fc16ce14f00000d''' 컨트롤러 액션에 의해 게시지고 있지만,이 배너에 저장 결코 극복을위한 몽고 문서 ID? – thoughtpunch

답변

관련 문제