Closed kouwasi closed 2 years ago
Aww, I found the solution.
I solved with delete self.primary_key
declaration.
On a model having composite pk declaration, primary_key
method returns string of array. (eg. "[:my_id, :other_id]"
)
So, that why generator can't work correctly.
This is correct way IMO.
Thanks for reporting this issue.
If my understanding is correct, Rails doesn't support composite PK officially, but the gem does.
I'd like to focus on Rails' official feature for RBS Rails. RBS Rails is designed to generate types for "rails" gem, but not for other extension gems.
I think RBS Rails should be extendable for extensions such as composite_primary_key, but currently, it does not have a public API to extend it. Sorry for the inconvenience.
Rails doesn't support composite PK officially
That's true.
In my case, I'm using many to many join table with composite pk.
But it is not correct way on ActiveRecord(and RDB?), I guess.
Actually, rails shown the warning Active Record does not support composite primary key.
Sorry for the inconvenience.
Don't worry about it! I think you are right to follows official Rails apis.
When try to generate that AR model's rbs, The generator can't generate rbs correctly.
Ruby: 3.1.2 Rails: 6.0.6