stefankroes/ancestry

having trouble displaying tree in select across different models/controllers

mices opened this issue · 0 comments

mices commented

Please help? In my items index view I'm trying to create a collection_select list using the Category model to allow the user to select the Category so I need a hyphen character for each of a categories parents with the list arranged by parents/children I have a routine defined in the Category model and I'm calling it in my view
undefined local variable or method `depth' for ItemType:Class
from Category.rb:
def self.name_for_selects
"#{'-' * depth} #{name}"
end
and from items/index.html.erb
<%= f.collection_select :category_id, @categories, :id, Category.name_for_selects, :include_blank => true %>