Rails 7 model generator not including references
I ran into a perplexing issue today with the Rails 7.0.6 model generator not actually generating the references tag.
Here's what I was attempting to do:
rails g model Waitlist name:string --primary-key-type=uuid daycare:references
The model it created should a string field, name and references to the daycare table. Or so I thought. No matter how many times I ran this generator and the subsequent db:migrate
my reference fields just didn't exist.
I proceeded to rubber duck the problem to a friend on Discord and no sooner had I typed it out and hit Send
that I realized that the order probably matters.
rails g model Waitlist name:string daycare:references --primary-key-type=uuid
MAGIC - everything was generated as expected. Happy rubying!