awesome_nested_set

8 views
Skip to first unread message

fugee ohu

unread,
Nov 17, 2019, 9:27:04 AM11/17/19
to Ruby on Rails: Talk
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}" } %>

Siyanda Maphumulo

unread,
Nov 17, 2019, 10:15:18 AM11/17/19
to Ruby on Rails: Talk
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)) %>


fugee ohu

unread,
Nov 17, 2019, 10:35:15 AM11/17/19
to Ruby on Rails: Talk
Yes
Reply all
Reply to author
Forward
0 new messages