Skip to content

Instantly share code, notes, and snippets.

@juan-fdz-hawa
Created February 20, 2020 19:23
Show Gist options
  • Select an option

  • Save juan-fdz-hawa/03dc8d35b56dc40cc16baf939a0a5b7e to your computer and use it in GitHub Desktop.

Select an option

Save juan-fdz-hawa/03dc8d35b56dc40cc16baf939a0a5b7e to your computer and use it in GitHub Desktop.

Revisions

  1. juan-fdz-hawa created this gist Feb 20, 2020.
    22 changes: 22 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    <%= f.input :author,
    :as => :grouped_select,
    :collection => [['Authors', ['Jose', 'Carlos']], ['General', ['Bob', 'John']]],
    :group_method => :last %>

    <%= f.input :author,
    :as => :grouped_select,
    :collection => Proc.new { [['Authors', ['Jose', 'Carlos']], ['General', ['Bob', 'John']]] },
    :group_method => :last %>

    <%= f.input :author,
    :as => :grouped_select,
    :collection => { ['Jose', 'Carlos'] => 'Authors' },
    :group_method => :first,
    :group_label_method => :last %>

    <%= f.input :author,
    :as => :grouped_select,
    :collection => { 'Authors' => ['Jose', 'Carlos'] },
    :group_method => :last,
    :label_method => :upcase,
    :value_method => :downcase %>