Skip to content

Commit b5efb03

Browse files
committed
Add ActiveRecord::Relation#table_name type
## Overview `ActiveRecord::Relation#table_name` is delegated to the model class via `method_missing`, but it was not defined in the RBS type definitions. This causes Steep to report a `NoMethodError` when calling `table_name` on a Relation instance. This PR adds the `table_name` method definition to `ActiveRecord::Relation` with a return type of `String`. ## References - Source: `ActiveRecord::ModelSchema::ClassMethods#table_name` - https://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-table_name - https://github.com/rails/rails/blob/v7.0.8/activerecord/lib/active_record/model_schema.rb#L247-L250
1 parent 9c796e7 commit b5efb03

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

gems/activerecord/6.0/activerecord.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ module ActiveRecord
400400
include Sanitization::ClassMethods
401401

402402
def arel_table: () -> Arel::Table
403+
404+
def table_name: () -> String
403405
end
404406
end
405407

gems/activerecord/7.2/_test/activerecord-7.2.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ class Article < ApplicationRecord
8989
User.order(:id).unscope(:order)
9090
User.reorder(id: :asc)
9191
User.order(id: :asc).reorder(id: :desc)
92+
93+
User.all.table_name
9294
end

gems/activerecord/7.2/activerecord.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ module ActiveRecord
407407
include Sanitization::ClassMethods
408408

409409
def arel_table: () -> Arel::Table
410+
411+
def table_name: () -> String
410412
end
411413
end
412414

gems/activerecord/8.0/_test/activerecord-8.0.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ class Article < ApplicationRecord
8989
User.order(:id).unscope(:order)
9090
User.reorder(id: :asc)
9191
User.order(id: :asc).reorder(id: :desc)
92+
93+
User.all.table_name
9294
end

gems/activerecord/8.0/activerecord.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ module ActiveRecord
407407
include Sanitization::ClassMethods
408408

409409
def arel_table: () -> Arel::Table
410+
411+
def table_name: () -> String
410412
end
411413
end
412414

0 commit comments

Comments
 (0)