Skip to content

Instantly share code, notes, and snippets.

@EtienneDepaulis
Last active February 4, 2023 13:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EtienneDepaulis/6988148 to your computer and use it in GitHub Desktop.
Save EtienneDepaulis/6988148 to your computer and use it in GitHub Desktop.
Generating a grouped collection select with `simple_form`and a model using the `ancestry` gem
<%=
f.association :category_id, collection: Category.roots,
as: :grouped_select,
group_method: :children, group_label_method: :name,
label_method: :name
%>
class Category < ActiveRecord::Base
attr_accessible :name
has_ancestry orphan_strategy: :adopt
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment