I'm currently using a standard one-to-one relationship to handle parent/child relationships:
class Category < ActiveRecord::Base
has_one :category
belongs_to :category
end
Is there a recommended way to do it or is this ok?
have certain qualities that remain constant. They are built on safety, unconditional love, mutual respect, acceptance and flexibility.
A form of filial therapy, child-parent relationship theory (CPRT) teaches parents to use child-centered play therapy (CCPT) skills with their children. Based on attachment theory, CPRT espouses that a secure bond between parent and child is mandatory for children's healthy development.
Trust and respect are essential to a positive parent-child relationship. In the early years with your baby, developing trust is important. Your baby will feel secure when they learn they can trust you and other main carers to meet their needs.
You will need to tweak the names you are using to get this working - you specify the name of the relationship, and then tell AR what the class is:
class Category < ActiveRecord::Base
has_one :child, :class_name => "Category"
belongs_to :parent, :class_name => "Category"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With