When trying to add attachment "image" to model "product" using gem CarrierWave, I used the following steps:
Created a new column with
rails g migration AddImageToProduct
However, I found out that even after repeated
db:reset commands, I still could not get the uploader working. I then realized that in the
schema.rb file that the "image" had not been added as a column, so the migration had failed.
The fix was to run the following commands:
db:seedcommand is optional as I had manipulated the
seed.rb file to create an admin account and normal account everytime the database is recreated.)
This fixed the database issue and now the
schema.rb file has the "image" column added, and I could upload images successfully. Apparently when running
db:reset, even though the system drops and recreates the database, it takes the old schema document rather than re-running all the migration files to update the schema.