You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for your work, it a great gem. But I have some issue while using single table inheritance. Models are listed below:
class User < ActiveRecord::Base
groupify :group_member, group_class_name: 'Department'
end
class Group < ActiveRecord::Base
groupify :group
end
class GroupMembership < ActiveRecord::Base
groupify :group_membership
end
class Department < Group
has_ancestry
has_members :users
def add_employee(u)
self.add u, as: :employee
end
def add_manager(u)
self.add u, as: :manager
end
def remove_employee(u)
u.groups.delete self
end
def remove_manager(u)
u.groups.delete self
end
end
I can add a user to a department as well, but when I trying to delete it from the department, it not works, and the sql is:
DELETE FROM "group_memberships" WHERE "group_memberships"."member_id" = ? AND "group_memberships"."member_type" = ? AND "group_memberships"."group_type" = 'Group' AND "group_memberships"."group_id" = 1 AND "group_memberships"."group_type" = ? [["member_id", 1], ["member_type", "User"], ["group_type", "Group"]]
But the relationship generated in group_memberships, the group_type is Department, so nothing happened after the deletion sql.
This also happens while retrieving department members, department.users runs this sql:
SELECT DISTINCT "users".* FROM "users" INNER JOIN "group_memberships" ON "users"."id" = "group_memberships"."member_id" WHERE "group_memberships"."group_id" = ? AND "group_memberships"."group_type" = ? AND "group_memberships"."member_type" = 'User' AND "group_memberships"."membership_type" = ? [["group_id", 1], ["group_type", "Group"], ["membership_type", :manager]]
It wont find anything because of wrong group_type, can you give more detail of using single table inheritance? It would be a big help, thank you
The text was updated successfully, but these errors were encountered:
I was having trouble with this too.
Whenever I add a member to a class that inherited from Group, the group type on those member would all be Group not the class name that inherited from Group
@0000sir@asafigan I don't seem to have the described problem deleting and selecting using the branch I'm working on to do some refactoring. Could you see if the bug is fixed for you?
@0000sir@asafigan have you guys checked out #61 for single-table inheritance and polymoprhic improvements? This may become the 1.0 release of Groupify, so your feedback on this refactor is greatly appreciated. Thanks.
Thank you for your work, it a great gem. But I have some issue while using single table inheritance. Models are listed below:
I can add a user to a department as well, but when I trying to delete it from the department, it not works, and the sql is:
But the relationship generated in group_memberships, the group_type is Department, so nothing happened after the deletion sql.
This also happens while retrieving department members, department.users runs this sql:
It wont find anything because of wrong group_type, can you give more detail of using single table inheritance? It would be a big help, thank you
The text was updated successfully, but these errors were encountered: