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