0
class Offer < ActiveRecord::Base
attr_accessible :name, :admin_id, :guest, :depart, :return, :adult, :kid
attr_accessible :guests_attributes, :payments_attributes
has_many :guests, :dependent => :destroy
has_many :payments, :dependent => :destroy
belongs_to :admin
accepts_nested_attributes_for :guests 
accepts_nested_attributes_for :payments

end

在控制器中

class PaymentController < ApplicationController

def new

@offer=Offer.new
@guest = @offer.guests.build
@payment=@offer.payments.build

end

我在模型中添加了 guest_attributes、payments_attributes。我仍然收到此错误。谁能帮我?

4

1 回答 1

2

听起来您的表单或 JSON/XML 正在发送带有键的嵌套对象guestsand payments,但它们必须是guests_attributesand payments_attributes。不过,看起来模型配置正确。

这个RailsCast可能会有所帮助。

于 2013-02-06T05:35:13.070 回答