Found out something about myself today. It seems I’m the person in the cohort who likes to ice skate uphill. What this means is that I make things unnecessarily complex in an effort to learn more.
My side project this week is to build a Craigslist junior app using the Sinatra framework, Active Record, and local Postgres database (aka “no Sqlite). In order to learn more I also decided that I would use RSpec and Jasmine as a way to learn/practice TDD (Test Driven Development) and JavaScript.
I started this project last Thursday, September 19th. Until today, Tuesday 9/24/2013, there was very little progress with this app as I was having difficulty setting up the Postgres database.
Some of the problems I encountered where:
- I was looking for a .db file. There isn’t one stored in your app with Postgres.
- I wasn’t using the rake generate:model or rake generate:migration commands to create a model and an empty migration.
- I did not realize that the app could be run from the root directory by just typing shotgun. I kept changing the environment so that Sinatra would run from the index file.
- Needed to add a gem called sinatra-activerecord to Gemfile, and a "set :database, ENV[‘DATABASE_URL’] || "postgres://localhost/#{APP_NAME}_#{Sinatra::Application.environment}” to database configuration file to close connections when app is uploaded to Heroku.
- Need to establish ActiveRecord::Base adapter to “:adapter => db.scheme == ‘postgres’ ? ‘postgresql’ : db.scheme,” and database name to db.path[1..-1].
As you can see lots of problems and frustration, but I’ve learned a ton. Will reassess if the headache is worth the pain after this project.
Stay connected