У меня есть три модели, а именно: «Employee :: TaxSettingBatch», «Employee :: HousingLoanInterest», «Employee :: InvestmentBankDetail».Эти модели связаны друг с другом следующим образом:
class Employee::TaxSettingBatch
include Mongoid::Document
has_one :housing_loan_interest, class_name: Employee::HousingLoanInterest'
accepts_nested_attributes_for :housing_loan_interest, allow_destroy: true
end
class Employee::HousingLoanInterest
include Mongoid::Document
field :property_type, type: String
belongs_to :employee_tax_setting_batch, class_name: 'Employee::TaxSettingBatch'
has_many :investment_bank_details, class_name: 'Employee::InvestmentBankDetail'
accepts_nested_attributes_for :investment_bank_details, allow_destroy: true
end
Проблема в том, что, когда я пытаюсь сохранить данные, я получаю ошибку ниже.
Проблема: Попытка установить значение для employee_housing_loan_interest, которое недопустимо в модели Employee :: TaxSettingBatch.
Мои параметры:
{"utf8"=>"✓",
"_method"=>"patch",
"authenticity_token"=>"Afig1spGvAgNX9bj7VEwRLO6FvTVH+ZOtNDBpEHY+LF4c10yn0KUHAlOn5oB/isfOwQF/VHjIcT7Etm2t0MHfA==",
"section"=>"housing_loan_info",
"employee_tax_setting_batch"=>
{"employee_housing_loan_interest"=>
{"property_type"=>"Self occupied property",
"_destroy"=>"false",
"investment_bank_details_attributes"=>
{"1545132357997"=>
{"loan_type"=>"Self",
"construction_completion_month_and_year"=>"jan 200",
"lender_bank_name"=>"hdfc",
"lender_pan_number"=>"bcopp15",
"loan_interest_details_attributes"=>
{"0"=>{"component"=>"Pre EMI Amount", "declared_amount"=>"2", "verified_amount"=>"3", "remarks"=>""},
"1"=>{"component"=>"Interest Repayment amount", "declared_amount"=>"2", "verified_amount"=>"3", "remarks"=>""}}}}}},
"disallowed_amount"=>"",
"controller"=>"employee/tax_setting_batches",
"action"=>"update",
"company_id"=>"55532e18517569120b7b0000",
"employee_id"=>"55532e18517569120b7c0000",
"tax_setting_id"=>"5bfe84d8c142e30aa0000125",
"id"=>"5c0f9676c142e309980002cb"}
Параметры для "employee_housing_loan_interest" не отправляются как "employee_housing_loan_interest_attributes", поэтому я получаю эту проблему.Помоги мне!
Моя форма:
<%= nested_form_for @tax_setting_batch, url: company_employee_tax_setting_tax_setting_batch_path(@company, @employee, @tax_setting, @tax_setting_batch), html: {id: 'form-80c-details', class: 'form-horizontal'}, remote:true,:authenticity_token=> true do |f| %>
<%= f.fields_for @tax_setting_batch.housing_loan_interest.nil? ? @tax_setting_batch.build_housing_loan_interest : @tax_setting_batch.housing_loan_interest , :wrapper => false do |form| %>