Answer the question
In order to leave comments, you need to log in
How to make a multi-level category model?
The task is to create a category model (name, description) - this is not a problem. The question is how to create a relationship between the two categories "Parent"->"Child". At the same time, make multi-level categories, for example
Clothing
- Children's clothing
- hats
- shoes
- Women's clothing
- Sweatshirts
, etc.
Answer the question
In order to leave comments, you need to log in
For example, a model where there is a parent_id pointing to the parent (for root it is nil)
class Category < ActiveRecord::Base
has_closure_tree
acts_as_tree
end
https://www.ruby-toolbox.com/categories/Active_Rec...
awesome-ruby.com/ (Tree: Ancestry ...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question