RolifyCommunity / rolify

Role management library with resource scoping
https://rolifycommunity.github.io/rolify/
MIT License
3.16k stars 404 forks source link

Exception in after_initialize of Role model rolify 5.3.0 #550

Open mkamensky opened 4 years ago

mkamensky commented 4 years ago

I have a method init in my Role model, which I call via after_initialize. After upgrading to rolify 5.3.0, I get an exception when I refer to name there:

ActiveModel::MissingAttributeError: missing attribute: name

I tracked the problem to be in this line: https://github.com/RolifyCommunity/rolify/blob/332fbd2f37462a24815c3c1656398e02990f19fe/lib/rolify/adapters/active_record/resource_adapter.rb#L29 I'm not sure this is actually an issue with rolify, but previously (without the to_a) all was fine

thomas-mcdonald commented 4 years ago

hey @mkamensky can you share some more of the backtrace? what does the callback + setup look like?

mkamensky commented 4 years ago

hey @mkamensky can you share some more of the backtrace? what does the callback + setup look like?

I created an example. Run rake fail

mkamensky commented 3 years ago

It seems like this is fixed by #559