Skip to content

Incorrect error message when mistyped validation in related association #46532

@loqimean

Description

@loqimean

Steps to reproduce

class Parent < ApplicationRecord
  has_one :child, dependent: :destroy
end

class Child < ApplicationRecord
  belongs_to :parent
  
  valisates :something, presen: true
end

Expected behavior

Rails shows error of mistyping, like a "method_missing': undefined method valisates' for Child:Class (NoMethodError)"

Actual behavior

Instead of this I have had an error:
"Rails couldn't find a valid model for Child association. Please provide the :class_name option on the association declaration. If :class_name is already provided, make sure it's an ActiveRecord::Base subclass.

      raise NameError, msg"

And spent a lot of my time to resolve this issue by a relation changing

System configuration

Rails version: 7.0.3

Ruby version: 3.1.2

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