Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in after_initialize of Role model rolify 5.3.0 #550

Open
mkamensky opened this issue Jul 7, 2020 · 3 comments
Open

Exception in after_initialize of Role model rolify 5.3.0 #550

mkamensky opened this issue Jul 7, 2020 · 3 comments

Comments

@mkamensky
Copy link

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:

roles = user.roles.where(:name => role_names).select("#{quote_table(role_class.table_name)}.#{quote_column(role_class.primary_key)}").to_a

I'm not sure this is actually an issue with rolify, but previously (without the to_a) all was fine

@thomas-mcdonald
Copy link
Member

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

@mkamensky
Copy link
Author

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
Copy link
Author

It seems like this is fixed by #559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants