Ruby on rails 具有多条记录的表单,未定义方法“model#u name';对于符号:类

Ruby on rails 具有多条记录的表单,未定义方法“model#u name';对于符号:类,ruby-on-rails,ruby-on-rails-3,activerecord,nested-forms,nested-attributes,Ruby On Rails,Ruby On Rails 3,Activerecord,Nested Forms,Nested Attributes,Rails3.2我在“:photos”的第一行得到一个错误,它表示Symbol:Class的未定义方法“model_name”。我迷路了 = simple_form_for [@tower, :photos], remote: true, html: {class: 'form-horizontal'} do |f| = f.error_notification .modal-body .modal-body-content .form-inputs

Rails3.2我在“:photos”的第一行得到一个错误,它表示Symbol:Class的未定义方法“model_name”。我迷路了

= simple_form_for [@tower, :photos], remote: true, html: {class: 'form-horizontal'} do |f|
  = f.error_notification
  .modal-body
    .modal-body-content
      .form-inputs
        - @photos.each_with_index do |photo, index|
          = simple_fields_for photo do |p|
            = render 'form_inputs', f: p, count: index
  .modal-footer
    = f.submit 'Save', class: 'btn btn-primary'
    button.btn type="button" data-dismiss="modal" Cancel
_


同样在tower.rb中,“接受嵌套的属性:照片”

也在关注这篇文章。你确定@tower确实包含一个tower对象实例还是空的?是的,它有一个objects实例,不是空的
# GET /towers/1/photos/new
def new
  @tower = Tower.find(params[:tower_id])
  @photos = Array.new(3){ @tower.photos.build }

  respond_to do |format|
    format.html # new.html.slim
    format.json { render json: @photos }
  end
end