2012-05-29 1 views
2

EnquiryFormUniversityFeeInstallment 사이에 일대 다 많은 관계가 있습니다. EnquiryForm has_many UniversityFeeInstallment. 다음
내가 라이언 베이츠에게 고전 중첩 된 형태의 기술을 사용하고저장하지 않기 위해 몽고이 - 수용 _ 중첩 된 _attributes

내가 콘트롤

{ 
"utf8"=>"✓", 
"authenticity_token"=>"jqgiRlk606pDzMEAtS/mGoWz8T61PgyCkKdMzSHEiQA=", 
"enquiry"=>{ 
    "university_fee_installments_attributes"=>{ 
     "1338318502006"=>{ 
      "due_date"=>"2012-05-28", 
      "amount"=>"1200" 
     } 
    } 
}, 
"commit"=>"Update Enquiry", 
"id"=>"4fc3db492d6d130238000028" 

}에서받는 params입니다. 또한 모델 코드는 다음과 같습니다

has_many :development_fee_installments, :autosave => true 
    has_many :university_fee_installments, :autosave => true 
    accepts_nested_attributes_for :development_fee_installments 
    accepts_nested_attributes_for :university_fee_installments 

컨트롤러 :

def update 
    @enquiry = Enauiry.find(params[:id]) 
    if @enquiry.save 
    redirect_to enquiry_payments_path(@enquiry, :notice => "Installment details updated") 
    else 
    render 'edit_installments' 
    end 
end 

내가 university_fee_installments을 저장할 수 없습니다입니다.

+0

컨트롤러 코드를 알려주십시오. – abhas

+0

@Cage : 업데이트 된 컨트롤러 코드 – Pravin

답변

1
우리가 그에서보기에서받은 PARAMS를 통과하는대로 트릭을 할 것이

def update 
    @enquiry = Enquiry.find(params[:id]) 
    if @enquiry.update_attributes(params[:enquiry]) 
     redirect_to enquiry_payments_path(@enquiry, :notice => "Installment details updated") 
    else 
     render 'edit_installments' 
    end 
end 

update_attributes에 컨트롤러 코드를 변경

.

+0

Ohh my god ... 어떻게 생각하세요? 피곤해 보입니다. 휴가가 필요해 .. :) – Pravin