rails formtastic更复杂的关联

时间:2012-12-28 19:26:54

标签: ruby-on-rails formtastic

所以我有以下型号:

国家 市 公司 CompanyOffice

连接是这样的:

公司-1:n->公司办公室 - >城市 - >国家

所以现在我有一个公司模型的formtastic表格。什么工作正常是改变公司模型中的所有内容。 但我想让用户输入公司的多个地址。

我试过了:

= semantic_form_for current_user.company, :url => url do |f|
  = f.input :name, :label => 'Company name'
  = f.input :logo, :label => 'Company Logo'
  ...

  = f.inputs :for => :company_offices do |co, i|
    = co.select :city, :collection => City.all, :label => 'City'
    = co.input :street, :label => 'Street'

这不起作用。你会怎么做?

1 个答案:

答案 0 :(得分:0)

您的模型中是否有嵌套属性? see