ryanb/nested_form未定义的方法`link_to_remove'for#

问题描述:

gem nested_form有点问题。我有:ryanb/nested_form未定义的方法`link_to_remove'for#<ActionView :: Helpers :: FormBuilder

class Factura < ActiveRecord::Base 
attr_accessible :itemfacturas_attributes 
has_many :itemfacturas 
has_many :productos, :through => :itemfacturas 
accepts_nested_attributes_for :itemfacturas, :reject_if => lambda { |a| a[:descripcion].blank? }, :allow_destroy => true 

和ItemFactura类

class Itemfactura < ActiveRecord::Base 
attr_accessor :vu, :vt, :descripcion 
belongs_to :factura 
belongs_to :producto 

我用的宝石在facturas /新视图添加itemfacturas。

<%= f.fields_for :itemfacturas do |b| %> 
     <%= render 'itemfacturas/itemfacturas', f: b %> 
<% end -%> 
<%= f.link_to_add "Agregar item", :itemfacturas %> 

和部分是:

<%= f.number_field :cantidad, :min => 0, :value => 1 %> 
<%= f.text_field :descripcion, :class => "desc_autocomplete" %> 
<%= f.text_field :vu %> 
<%= f.text_field :vt %> 
<%= f.hidden_field :producto_id%> 
<%= f.link_to_remove "Eliminar" %> 

但我有此错误:

NoMethodError in Facturas#new

Showing /Users/fabricioflores/desarrollo/facturacion/app/views/itemfacturas/_itemfacturas.html.erb where line #7 raised:

undefined method `link_to_remove' for

如果我的评论包含link_to_remove我对link_to_add

我另一个错误行其次从https://github.com/ryanb/nested_form步骤,但它没有工作。我正在使用Rails 3.2.9和nested_form(0.3.1)

好吧,我解决了它。在facturas形式/新我需要把

<%= nested_form_for @factura do |f| %> 

这是无法找到link_to_add和link_to_remove的原因,因为是不同的帮手。