I have a Rails model which has_many items:
class Plan < ApplicationRecord
extend T::Sig
has_many :items, dependent: :destroy
before_save do
# hyper simple test method to illustrat problem
puts items
end
end
However Sorbet can't seem to relate to the has_many :items. When I run Sorbet typechecking I get the following error:
$ srb tc
app/models/plan.rb:11: Method items does not exist on T.class_of(Plan) https://srb.help/7003
11 | items
^^^^^
Did you mean:
sorbet/rails-rbi/models/plan.rbi:86: Plan::GeneratedAssociationMethods#items
86 | def items; end
The answer to Sorbet's question is yes - I do mean that method. Where is the confusion coming from? Why doesn't the definition of .items in the RBI file satisfy Sorbet's need to know where this method is defined?