Is this view helper valid for @category=Category.new because I tried it, I get a nil list
<%= f.select :parent_id, nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" } %>
Hi, when u say u get a nil list, does the dropdown select render but it does not contain any items ?
I’m not familiar with “awesome_nested_set” but I have tried to do something with a select in the past and I found “The Odin project” examples were helpful I’ve pasted the code below, it creates an array with the model name and id, and here’s a link to the page : advanced-forms
I hope it helps
# app/controllers/posts_controller.rb
...
def new
@user_options = User.all.map{ |u| [ u.name, u.id ] }
@post = Post.new
end
...
# app/views/posts/new.html.erb
...
<%= select_tag(:author_id, options_for_select(@user_options)) %>
Yes