Created
February 8, 2017 14:33
-
-
Save lbvf50mobile/b4b492c2c666a01aa1f3480f9a6be6fb to your computer and use it in GitHub Desktop.
Category model that have self association.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Category < ActiveRecord::Base | |
has_many :sub_cat, class_name: "Category", | |
foreign_key: "categoriable_id" | |
belongs_to :main_cat, class_name: "Category" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment