Closed mattandayo closed 9 months ago
require "active_hash"
class Category < ActiveHash::Base
include ActiveHash::Associations
has_many :children, foreign_key: :parent_id, class_name: "ChildCategory"
fields :name
add id: 1, name: 'name'
add id: 2, name: 'name'
end
class ChildCategory < ActiveHash::Base
include ActiveHash::Associations
belongs_to :parent, foreign_key: :parent_id, class_name: "Category"
fields :parent_id, :name
add id: 1, parent_id: 1, name: 'name'
add id: 2, parent_id: 2, name: 'name'
end
puts Category.last.children
puts ChildCategory.last.parent
let me know if that gives you issues
Hi ✋ Thank you for developing a great gem!!
I expect the following behavior.
However, I get errors
Please tell me what the problem is.
Environment