Question

I have using awesome_nested_set with active_admin. But I found that active_admin can't find nested_set_options method

My active_admin code

    ActiveAdmin.register Category do
      form do |f|
        f.inputs "Category Details" do
          f.input :name,            :label => "Category name"
          f.input :parent_id,   :label => "Parent Category",    :as => :select, :collection => nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" }
        end
        f.buttons
      end 
    end
Was it helpful?

Solution

try

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

inside the aa ~ formtastic dsl bridge you can access view helpers from f.template

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top