【问题标题】:nested attributes without activerecord没有活动记录的嵌套属性
【发布时间】:2013-03-13 21:19:37
【问题描述】:

我正在尝试创建一个不保存到数据库但传递到第三方系统的发票系统。因此,我的模型不是 ActiveRecord,因为没有要持久保存的表。如何在我的发票模型中接受发票行项目的嵌套属性?

这是我的表单中生成的参数的示例

{"payportal_invoice"=>{"invoice_lines"=>{"quantity"=>["1", "2"], "units"=>["hours", "hours"], "price"=>["10", "20"], "description"=>["desc", "d"]}, "dueDate"=>"10/10/2013", "invoiceNumber"=>"3.13.13.11:47", "description"=>"notes"}, "attachment_name"=>""}

我可以通过这个参数集轻松创建发票模型,但不知道如何创建行项目

【问题讨论】:

    标签: ruby-on-rails-3 model-view-controller nested-attributes


    【解决方案1】:

    您是否尝试过使用无表 gem,例如 https://github.com/softace/activerecord-tableless

    我过去曾将它们用于类似情况 - 您可以执行所有标准验证等,但无需调用 ActiveRecord。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-25
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多