On Sunday, November 17, 2019 at 10:15:18 AM UTC-5, Siyanda Maphumulo wrote: > > 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 > <https://www.theodinproject.com/courses/ruby-on-rails/lessons/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)) %> > > > > > > > > > On Sunday, 17 November 2019 16:27:04 UTC+2, fugee ohu wrote: >> >> 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}" } %> >> >> Yes
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7b3f7a33-4129-43ec-bafa-4f94bf7ae880%40googlegroups.com.