Answer the question
In order to leave comments, you need to log in
How to organize a tree model that is part of another model?
class User < ActiveRecord::Base
has_and_belongs_to :folders
end
# ...
# migration
class UsersFolders < ActiveRecord::Migration
def change
create_table :folders_users, id: false do |t|
t.belongs_to :user
t.belongs_to :folder
end
end
end
# ...
class Folder < ActiveRecord::Base
has_ancestry
has_and_belongs_to: users
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question