0

我有三个模型,,NeoUser由设计自动生成)和Observation

每个User has_many Neos 和Observations。每个Neo has_many观察和belongs_to一个User. 一一Observation belongs_to一一。Neo_User

我需要为 Neo 创建一个 simple_form,它应该允许我动态添加 Observations(a la Polldaddy 投票选项)。这是我的表单代码:

- title "Add a NEO"

= simple_form_for @neo do |nf|
    = nf.input :name
        = nf.simple_fields_for :observations do |of|
            = of.input :ra
            = of.input :dec

    = nf.button :wrapped

这会返回一个ActiveRecord::UnkownAttributeError说法“未知属性neo_id”。

我怎样才能解决这个问题?

4

1 回答 1

0

我的缩进是错误的:

- title "Add a NEO"

= simple_form_for @neo do |nf|
    = nf.input :name
        = nf.simple_fields_for :observations do |of|
            = of.input :ra
            = of.input :dec

    = nf.button :wrapped

本来应该:

- title "Add a NEO"

= simple_form_for @neo do |nf|
    = nf.input :name
    = nf.simple_fields_for :observations do |of|
        = of.input :ra
        = of.input :dec

    = nf.button :wrapped
于 2013-04-21T06:23:29.017 回答