I’ve been following along with this great video course on BaseRails, from Alex Yang. Alex walks you through starting a Rails app from scratch. He explains what gems are needed, styling your app with Bootstrap, and brings up some issues that may arise when building rails apps. All videos come with provided code, as well as a discussion area for asking questions. Alex does a great job of responding pretty quickly and is willing to help you with issues. The course available right now explains how to build an app similar to Etsy. It’s really shown me the power of Rails, and I’m hooked! I did read that other courses will be coming shortly. I highly recommend it.

I caused an error when trying to add extra columns/entries? to our database. One of the gems we are using with this project is called Devise. Devise helps with user sign-ups, sign-ins, authentication, etc etc. The Devise gem automatically adds EMAIL and PASSWORD entries to our database, but that is all. In the course, we are instructed to add an entry for our user’s NAME. I have my own app in mind as I follow along, and I know I will need much more than just adding a NAME entry. I wanted to add STATE, CITY, and EMAIL to the database as well.

Did you catch that? I said EMAIL. EMAIL is already there because of the Devise gem. I wasn’t thinking and tried to add EMAIL again! I didn’t realize it at first though. Obviously, I got an error when trying the “rake db:migrate” command in Terminal. When I tried to visit my app page I got the “Pending Migrations” error: “Migrations are pending; run ‘rake db:migrate RAILS_ENV=development’ to resolve this issue”. Running that command didn’t work for me. I searched for a while on StackOverflow, but none of the issues I found specifically matched mine. I then went back to Terminal and examined what was going on. I was able to find the exact point where the error happened. It explicitly told me that EMAIL was already a part of my database. Crap!

So I searched for, “how to revert a rails migration” on StackOverflow and went with this one, which is about using the “rake db:rollback” command to go back a step.

I ran it. Then ran it again. Oops! I don’t know why I did it twice. So now I’ve gone too far back. I go back to the question and see that you can do “rake db:migrate:down VERSION=XXXXXXXXXX” to specifically delete a database migration. I went back to my command line and found the specific EMAIL migration identifier that was causing the error and did the command. No luck. Still throwing the error when trying to access the app. Crap again.

So I decided to go into my app’s db/migrations folder and delete the duplicate migration that was causing havoc.

Now everything is working correctly along with my added STATE and CITY entries. I’m happy that I was able to get this to work, but I obviously need to do a little more experimenting on the migration commands. Instead of manually going into the directory to delete the migration, I know there is a correct way to do it from the command line.
Alex did tell me that running, “rake db:migrate:status”, will be helpful in these situations too.

The app I have in mind is called Isement. It will be a marketplace to buy and sell physical advertising in unique or “out of the ordinary” places. It’s being hosted for free right now, and Heroku puts your app to “sleep” when not in use, so give it a few seconds to wake up when accessing.