I've got a problem with an id column created with a scaffold. I generated a scaffold with following command:
rails generate scaffold scaffoldname name:string id:integer
I used that id column for a relation which I wanted to use for a dropdown menu with collection_select
. Afterwards I realized that generating an id is unnecessary because of the id which rails creates automatically for each table.
When I wanted to call the related table with the self-created id this is of course possible with
class.relatedClass.id
Afterwards I realized that this command is also possible in a table where rails created the id, although the column is named "rowid" in the table.
So i thought that It should be possible to delete the self-created id column with a migration. The way I thought about this was, that rails should then use automatically the rowid for the relation. But after deleting the self-created id there are errors all around. Rails refuses to use the 'rowid' column automatically although it does it in case there was no id column specified in the scaffold command.
How do I delete that self-created id column in a way that rails uses their own created rowid afterwards when calling class.relatedClass.id
?