Skip to content

acts_as_token_authenticatable adds unnecessary methods to ActiveRecord::Base #345

@philayres

Description

@philayres

While working through the PR for #300 I found that adding an override for the attribute authentication_token caused one of my Rails apps to fail. This was reporting ActiveRecord::DangerousAttributeError on the attribute.

After digging around I found that acts_as_token_authenticatable really doesn't do much. The file it is defined in gets applied to ActiveRecord::Base, which meant that all changes made in there become part of that Base class. This led to ActiveRecord noticing that the attribute I was attempting to override was overriding what it considered to be core ActiveRecord functionality.

I have worked up a PR to split out acts_as_token_authenticatable so that the underlying functionality is only applied to the models the method call appears in. This follows the approach I see you already have for the controller handler acts_as_token_authentication_handler.

Unfortunately this PR was worked up based on the work already done for #300. It doesn't make sense in my opinion to go back and rework everything against the current version, so I propose that the PRs for this issue and #300 be adopted together. I hope you are OK with that.

I'll submit the new PR once we've made progress on the first one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions