Week 9, day 2

Today we finished off Gym Buddy and all teams had to present their hackathon websites. It's been an intense and very rewarding couple of days.

Use Gym Buddy on Heroku

gymbuddy landing page

The Gym Buddy repository

Rather than repeat myself I'm just going to paste here what I learned from this project:


What we learned:

1 - Teamwork!

It's enough of a challenge to pair effectively but working in small teams to hack an app together in less than 48 hours is new to all of us. Getting our team cohesion and dynamics sorted was job one and it went great! Major kudos to all of the team for really coming together and working our magnificent butts off.

img


2 - Kanban boards.

We've heard of these mystical things but this was our first time actually using them and I have to admit they are very useful.

img


3 - Rspec and Capybara are awesome!

It's so nice to come back to Ruby and Rspec. Our first hurdle was how to select items from a date-picker for our tests. We started using select('Option', from: 'Select Box') from this awesome Capybara cheatsheet. But that didn't work out of the box. Instead we found this picker helper from which we got the inspiration to write our own version:

def select_date_and_time(date, options = {})
  field = options[:from]
  select date.strftime('%Y'), :from => "post_day_1i" #year
  select date.strftime('%B'), :from => "post_day_2i" #month
  select date.strftime('%d'), :from => "post_day_3i" #day
  select date.strftime('%H'), :from => "post_time_4i" #hour
  select date.strftime('%M'), :from => "post_time_5i" #minute
end

4 - ActiveRecord database issues

We dreaded it, we prayed it wouldn't happen, but it happened. A lot! In the early stages of development it was easy to simply rollback migrations but once our app was further along in development we had to target migrations for destruction and recreation. We had used text as our date and time data types and had to change them to their dedicated types, time and date.

From here we worked out these:

First rails g migrate like this:

rails g migration change_day_format_in_posts_table
rails g migration change_time_format_in_posts_table

then in the db migrate file:

class ChangeDayFormatInPostsTable < ActiveRecord::Migration
  def change
    remove_column :posts, :day
    add_column :posts, :day, :date
  end
end

and

class ChangeTimeFormatInPostsTable < ActiveRecord::Migration
  def change
    remove_column :posts, :time
    add_column :posts, :time, :time
  end
end

5 - Travis-CI and Coveralls CC

Make a .travis.yml in the root and add to it:

rvm: '2.2.1'
script: bundle exec rspec spec
script:
  - bundle exec bin/rake db:create
  - bundle exec bin/rake db:migrate
  - bundle exec rspec spec

For Coveralls CC to spec/spech_helper.rb at the top add:

require 'coveralls'
Coveralls.wear!

and in the gemfile:

gem 'coveralls', require: false

6 - Heroku DB

Nothing really comes to mind with the deploy, it all went pretty smoothly. The only issues we really had were related to the DB but it was pretty straight forward.

Every few deploys we would get some errors and usually a DB reset and migrate sorted them out.

heroku run rake db:reset
heroku run rake db:migrate
Written on May 12, 2015