We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
In my project, the rbs_rails:generate_rbs_for_models task fails with my model that has a composite primary key.
It happens with rbs_rails: v0.12.1
NoMethodError with message undefined method 'type' for nil.
NoMethodError
undefined method 'type' for nil
RbsRails::ActiveRecord::Generator#pk_type in lib/rbs_rails/active_record.rb:60
pk is at this point ["year", "user_id"] when klass is UserHolidayYear.
pk
["year", "user_id"]
klass
UserHolidayYear
private def pk_type pk = klass.primary_key return 'top' unless pk # pk => `["year", "user_id"]` when `klass.name == 'UserHolidayYear'` col = klass.columns.find {|col| col.name == pk } sql_type_to_class(col.type) end
class UserHolidayYear < ApplicationRecord self.primary_key = %i[year user_id] # ... belongs_to :calendar_year, foreign_key: :year, primary_key: :year, inverse_of: :user_holiday_years belongs_to :user # ... end class CalendarYear < ApplicationRecord self.primary_key = :year # ... end ActiveRecord::Schema[8.0].define(version: 2025_02_06_152444) do # ... create_table "user_holiday_years", id: false, force: :cascade do |t| t.integer "year" t.bigint "user_id", null: false # ... t.index ["year", "user_id"], name: "index_user_holiday_years_on_year_and_user_id", unique: true end # ... end
The text was updated successfully, but these errors were encountered:
fix(active_record::generator): #pk_type fails when model has composit…
f2b87fc
…e primary key Attempting to resolve my own issue: pocke#297 Resolve pocke#297
2c36a56
af38694
2fc8459
Successfully merging a pull request may close this issue.
Error description
In my project, the rbs_rails:generate_rbs_for_models task fails with my model that has a composite primary key.
It happens with rbs_rails: v0.12.1
Error thrown
NoMethodError
with messageundefined method 'type' for nil
.Where exactly
RbsRails::ActiveRecord::Generator#pk_type in lib/rbs_rails/active_record.rb:60
pk
is at this point["year", "user_id"]
whenklass
isUserHolidayYear
.My model
The text was updated successfully, but these errors were encountered: