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
My application has Users and many kinds of Applications (with STI). Users can have roles on Applications. I was hoping to use STI with resourcify, only applying resourcify on the base Application class.
Currently, if I add resourcify to the base class, the Role gets created, but when I try User.first.roles, the ApplicationSubType resources aren't found.
For now, I'm just going to add resourcify to every Application sub-type, and it's fine. However, it would be nice to have more native support from Resourcify.
it seems like simply allowing an option to override self.name to always use Application as the resource name would be a simple-enough fix; that said, I haven't looked into the issue deeply.
Let me know if this seems at all feasible - happy to send in a PR.
The text was updated successfully, but these errors were encountered:
I ran into something similar and found this issue as well as #203. I think I have resolved it by modifying the resource type within the Roles class to make sure Rolify is always using the base class for STI associations.
#app/models/role.rb
class Role < ApplicationRecord
...
def resource_type=(type)
super(type.to_s.classify.constantize.base_class.to_s)
end
...
end
My application has Users and many kinds of Applications (with STI). Users can have roles on Applications. I was hoping to use STI with
resourcify
, only applyingresourcify
on the base Application class.Currently, if I add
resourcify
to the base class, the Role gets created, but when I tryUser.first.roles
, the ApplicationSubType resources aren't found.For now, I'm just going to add
resourcify
to every Application sub-type, and it's fine. However, it would be nice to have more native support from Resourcify.Looking at https://github.com/RolifyCommunity/rolify/blob/99d886e8c5ba2f554f1c3573fcd91575a16dd3e5/lib/rolify.rb,
it seems like simply allowing an option to override
self.name
to always use Application as the resource name would be a simple-enough fix; that said, I haven't looked into the issue deeply.Let me know if this seems at all feasible - happy to send in a PR.
The text was updated successfully, but these errors were encountered: