I'm using awesome_nested_set to implement nested pattern in select tag. When there is no record in the database form is loading successfully, but after adding first category as base category whose parent_id is null this error is showing up
ActionView::Template::Error (no implicit conversion from nil to integer)
I've used view helper to implement this, my select tag looks like this
<%= f.select :parent_id, nested_set_options(Category, @category) {|i, level| "#{'-' * level} #{i.name}" } %>
Please help, how to get rid of this error, I'm using awesome nested set to implement this!
You need to use this:
You have a serious error in your block. As documented on the gem's page, the block passed to the
nested_set_options
only accepts a single argumenti
which is the category itself.level
is a method ofi
which you can get usingi.level
.