【发布时间】:2014-05-23 01:50:19
【问题描述】:
我有一个 Contract 和一个 Task_Order 模型。我不断收到unknown attribute error for contract_id 每个Contract has many Task Orders。我已阅读其他嵌套模型未知属性错误问题,但它们无法帮助我。请记住,我对 Rails 还很陌生,如果能得到任何帮助,我将不胜感激。我正在使用 Rails 4.0
合约模型:
has_many :task_orders
合约架构:
create_table "contracts", force: true do |t|
t.string "contractId"
t.string "contractName"
end
任务顺序模型:
belongs_to :contracts
任务顺序架构:
create_table "task_orders", force: true do |t|
t.string "contract_Id"
t.string "task_orderId"
t.string "task_orderName"
end
当我点击Show Contract 时,我得到了错误:
unknown attribute: contract_id
这是突出显示的行:
<%= form_for([@contract, @contract.task_orders.new]) do |f| %>
我可以看出 Rails 正在尝试打印出contract_id,这不在我的Contract 模型中......那么我怎样才能让它打印出contractId 而不是在我的Contract 中型号?
谢谢!!
【问题讨论】:
标签: ruby-on-rails ruby nested