Module Cocoon::ViewHelpers
In: lib/cocoon/view_helpers.rb

Methods

Public Instance methods

creates new association object with its conditions, like `` has_many :admin_comments, class_name: "Comment", conditions: { author: "Admin" } will create new Comment with author "Admin"

shows a link that will allow to dynamically add a new associated object.

  • name : the text to show in the link
  • f : the form this should come in (the formtastic form)
  • association : the associated objects, e.g. :tasks, this should be the name of the has_many relation.
  • html_options: html options to be passed to link_to (see link_to)
           - *:render_options* : options passed to `simple_fields_for, semantic_fields_for or fields_for`
               - *:locals*     : the locals hash in the :render_options is handed to the partial
           - *:partial*        : explicitly override the default partial name
           - *:wrap_object*    : a proc that will allow to wrap your object, especially suited when using
                                 decorators, or if you want special initialisation
           - *:form_name*      : the parameter for the form in the nested form partial. Default `f`.
           - *:count*          : Count of how many objects will be added on a single click. Default `1`.
    
  • *&block*: see link_to

this will show a link to remove the current association. This should be placed inside the partial. either you give

  • name : the text of the link
  • f : the form this link should be placed in
  • html_options: html options to be passed to link_to (see link_to)

or you use the form without name with a *&block*

  • f : the form this link should be placed in
  • html_options: html options to be passed to link_to (see link_to)
  • *&block*: the output of the block will be show in the link, see link_to

[Validate]