开发者

RailsCast 197: nested forms Unknown Attribute

I have two tables: Quote and Part. I am using the rails 3.1 ruby 1.9.2. My code is as follows:

class Quote < ActiveRecord::Base
attr_accessible :name, :customer_id, :part_id, :date, :quote_id
has_many    :customers
has_many    :cycles
has_many    :parts, #:dependent => :destroy
accepts_nested_attributes_for :parts 

end


class Part < ActiveRecord::Base
belongs_to :quote

end

QuotesController

def new
  @quote = Quote.new
  @customers=Customer.find(:all)
  @cycles = Cycle.find(:all)
  1.times {@quote.parts.build}

end

_form

<% f.fields_for :parts do |builder| %>
<%= render "cycle_fields", :f => builder%>

I am getting an unknown attribute: quote_id when I tr开发者_开发知识库y to render the form.


Run this migration

    rails g migration AddIdToPart quote_id:integer
    rake db:migrate
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜