Skip to content
russjohnson edited this page Sep 13, 2010 · 1 revision

The usage is trivial. First create a usual select (or collection_select) which
will act as “parent”. Afterwards you can create one or many dependent
child(ren) select(s) by calling:

related_collection_select( object, method, parent_select_tag, collection, value_method, text_method, reference_method, options = {}, html_options = {})

Arguments

  • ‘object’, ‘method’, ‘collection’, ‘value_method’, ‘text_method’,
    ‘options’ & ‘html_options’ are used exactly the same way as in
    the standard collection_select helper method.
  • ‘parent_select_tag’ specifies, as the name says, the parent
    select tag; argument can be passed as an array
    [:parent_object, :method] or directly as string referencing the
    tag id (e.g. “parent_object_method”)
  • Parameter ‘reference_method’ specifies the method that is used to get
    a reference to parent selection.

Additionally the ‘options’ argument can include a ‘:selected’ attribute,
that will override the default pre-selection behaviour (which uses to call
‘@object.method’ to determine the to be selected option).

Clone this wiki locally