Whenever I’ve had to do a HABTM in rails I’ve always found myself wondering if it’s possible to generate the required migration from the command line.
I was hoping to save time by just doing something like this:
rails g migration tracks_podcasts tracks:references podcasts:references id:false
The above code doesn’t work, and neither do several variations of it (with and without the id:false instruction)
According to the rails documentation, that should work, but you would want to replace ‘references’ with ‘integer’. ‘references’ isn’t a valid data type. And get rid of the id:false entry. The references and :id => false should be specified within the migration after generation. You will basically generate a basic migration with all the fields you want, then open the migration and modify it to meet your specs.