Skip to content

Automatic scope definition can break applications because of naming issues #7

@klyonrad

Description

@klyonrad

We get an error upon upgrading to boolean_timestamps 1.1.0

Sorry @jordanbyron but I think you introduced a bug with your latest feature addition 😿

Reproduction

model code

class SomeModel < ApplicationRecord
  boolean_timestamps :loaded_at
end

error

leads to

ArgumentError: You tried to define a scope named "loaded" on the model "SomeModel", but ActiveRecord::Relation already defined an instance method with the same name.

So boolean_timestamps tries to overwrite this method: https://www.rubydoc.info/docs/rails/ActiveRecord%2FRelation:loaded


Rails has some safeguards during scope definitions, See here

I propose to either respect those safeguards or make the scope definitions Opt-In/Opt-Out

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions