Skip to content

find_by_token_for and Rails/DynamicFindBy #781

Closed
@strobilomyces

Description

@strobilomyces

Context

rails/rails#44189 introduced a token generator and a lookup function called find_by_token_for

rubocop-rails confuses it for a model lookup and is not pleased.

I originally posted about this in rails/rails#46065 and was told this is a rubocop-rails issue, so here we are.

Expected behavior

No violations detected.

Actual behavior

C: Rails/DynamicFindBy: Use find_by instead of dynamic find_by_token_for.
    @user = User.find_by_token_for(:confirm_email_token, params[:confirmation_token])

Steps to reproduce the problem

RuboCop version

$ bundle exec rubocop -V
1.36.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.1.2) [x86_64-linux]
  - rubocop-rails 2.16.1

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions