Skip to content

STI resourcify .roles method issue #203

@RadoslawT

Description

@RadoslawT

Hello

I'm using Rolify 3.3.0.rc5 gem, and I have a problem with STI resourcify models, in my case Department < Group.

When I'm adding role for a Department Rolify adds it with resource Department. When I want to find all roles for the Department it looks for Group resource, so it returns nothing.

I've tried many combinations but nothing didn't work for me yet. Could you please give me any advices?

Console logs:

> User.last.add_role :test_role, Group.last
=> <Role id: 20, name: "test_role", resource_id: 35, resource_type: "Department", created_at: "2013-12-04 18:50:18", updated_at: "2013-12-04 18:50:18"> 

> Department.last.roles.size
  Department Load (1.0ms)  SELECT "groups".* FROM "groups" WHERE "groups"."type" IN ('Department') ORDER BY "groups"."id" DESC LIMIT 1
   (0.6ms)  SELECT COUNT(*) FROM "roles" WHERE "roles"."resource_id" = $1 AND "roles"."resource_type" = $2  [["resource_id", 35], ["resource_type", "Group"]]
 => 0 

> Group.last.roles.size
  Group Load (3.5ms)  SELECT "groups".* FROM "groups" ORDER BY "groups"."id" DESC LIMIT 1
   (0.7ms)  SELECT COUNT(*) FROM "roles" WHERE "roles"."resource_id" = $1 AND "roles"."resource_type" = $2  [["resource_id", 35], ["resource_type", "Group"]]
 => 0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions