Skip to content

Instantly share code, notes, and snippets.

@formigarafa
Created January 19, 2012 21:44
Show Gist options
  • Save formigarafa/1642969 to your computer and use it in GitHub Desktop.
Save formigarafa/1642969 to your computer and use it in GitHub Desktop.
Nested categories with Active Admin
ActiveAdmin.register Category do
extend CollectiveIdea::Acts::NestedSet::Helper
form do |f|
f.inputs do
f.input :name
f.input :parent_id, :as => :select, :collection => (nested_set_options(Category, @category) {|i, level| "#{'-' * level} #{i.name}" })
end
f.buttons
end
end
@gerardoacuna
Copy link

This didn't work for me. I had to use

f.input :parent_id, , :as => :select, :collection => (nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" } )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment