0

Web フォームに動的フィールドを追加するために cocoon gem を使用しています。6 つのフィールドのみを追加するように制限したいのですが、どうすればよいですか?

以下は、ヘルパーで使用しているコードです。

   def link_to_add_association(*args, &block)
if block_given?
  f            = args[0]
  association  = args[1]
  html_options = args[2] || {}
  link_to_add_association(capture(&block), f, association, html_options)
else
  name         = args[0]
  f            = args[1]
  association  = args[2]
  html_options = args[3] || {}

  html_options[:class] = [html_options[:class], "add_fields"].compact.join(' ')
  html_options[:'data-association'] = association.to_s.singularize
  html_options[:'data-associations'] = association.to_s.pluralize

  new_object = f.object.class.reflect_on_association(association).klass.new
  html_options[:'data-template'] = CGI.escapeHTML(render_association(association, f, new_object)).html_safe

  link_to(name, '#', html_options )
end

終わり

事前にご協力いただきありがとうございます。

4

1 に答える 1