The most challenging part of this year was getting the image uploader gem CarrierWave to work. I did these steps below:
- Installing the gem
- Loading the uploader in the model
- Adding a column using
rails g migration AddImageToProduct
- Adding the new column to the "product" controller
... yet the upload still returned error!
The error was that image was "nil", which meant that the image didn't get uploaded, or that in the product image wasn't attached. So I checked the schema document and realized that even though I ran
db:migrate, the image was never added to the schema - not sure why though.
First, I tried to fix this with
rake db:reset, which didn't work because it takes the schema document rather than updating it. Then I used rake db:drop, rake db:create, and rake db:migrate to recreate the database, which finally worked.
I wrote a more detailed version of the above issue here.