Ruby on Rails
Sunday, November 17, 2019
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)) %>
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}" } %>
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/44ed3010-8071-40ce-acaf-facce327992a%40googlegroups.com.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment