Cocoon link_to_add_association:ArgumentError:错误的参数个数(2个为1)

时间:2017-08-29 11:21:01

标签: ruby-on-rails ruby-on-rails-4 cocoon-gem ruby-2.2

我正在整合Cocoon,以便为我的属性对象添加多个附件。

但是当我创建新属性记录时,我收到buttonClicked()错误

try
{
    foo();
}
catch (Exception e)
{
    // HERE
}

/gems/cocoon-1.2.9/lib/cocoon/view_helpers.rb即之前  new_object = create_object(f,association,force_non_association_create)

ArgumentError: wrong number of arguments (2 for 1)

我有模特

= form_for @property, remote: true, authenticity_token: true, html: { class: "form-horizontal", multipart: true } do |f|
 .links
   = link_to_add_association 'Add', f, :attachments
 .modal-footer
   .actions
     %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Close
     = f.submit 'Save',  class: 'btn btn-warning'

宝石版

[1] pry(#<#<Class:0x0000000b46f630>>)> create_object(f, association, force_non_association_create)

ActionView::Template::Error (wrong number of arguments (2 for 1)):
   1: = form_for @property, remote: true, authenticity_token: true, html: { class: "form-horizontal", multipart: true } do |f|
   2:   .links
   3:     = link_to_add_association 'Add', f, :attachments
   4:   .modal-footer
   5:     .actions
   6:       %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Close
 app/views/properties/_form.html.haml:3:in `block in _app_views_properties__form_html_haml___4571956341154479101_90407280' 

from /home/dev05/.rvm/gems/ruby-2.2.2@me_backend/gems/activerecord-4.2.5.1/lib/active_record/attribute_methods/query.rb:35:in `attribute?'

Gemfile.lock文件快照

class Property < ActiveRecord::Base
 has_many :attachments, as: :attached_item, dependent: :destroy
 accepts_nested_attributes_for :attachments,allow_destroy: true
end

class Attachment < ActiveRecord::Base
 belongs_to :attached_item, polymorphic: true
end

有人可以帮我确定导致问题的原因是不创建附件。

0 个答案:

没有答案