Rails 5 – how to create a child before a parent

I’ve been hacking away on a personal budgeting app on my train rides and ran into a squirrely problem in rails 5.   My budgeting app uses the spectacular Quovo API (https://api.quovo.com/docs/v3/) to pull transactions from my Chase accounts.  Quovo rocks, it’s like Plaid or Yodlee, but has a free plan that gives you 100 free connections.

Anyway, the Quovo API brings back connections  and accounts, among other things.   The problem was that the webhooks came with the account information before the connection info.  I have my models set up with the connection as a parent to the child accounts.    Every time I tried to save the account without the connection created first, I got this error:

ActiveRecord::RecordInvalid: Validation failed: Connection must exist

30 minutes of diligent Googling led me to this great YouTube video by Ruby Thursday (https://twitter.com/rubythurs).

The answer?  The optional: true parameter, set like this:

class Account < ApplicationRecord
  belongs_to :connection, optional: true 

I added that and bang!  No more issues.

 

Advertisements
Posted in Uncategorized | Leave a comment

Build a ShareASale Website for $0.10 per month

One of my favorite co-workers in the last few years is my good friend Steven Maguire.    He’s one part hilarious, one part brilliant, and one part pragmatic.  One of my best coding memories from the last few years was figuring out how to fill in pdf’s using prawn, rails, and a handful of other gems to power form filling at EarthClassMail and to help people file medical claim forms online.

Steven loves to build fun things with a minimum of cost, and recently launched his newest funny venture, FootBallCropTop.com.   If you’re in the market for Wisconsin Badger crop tops, this is the site for you!

On a dev note, if you’ve ever wrestled with the ShareASale API and ShareASale coupon feeds, check out Steven’s article on how he elegantly handled both.   He gives a full rundown on how to use Github pages, Jekyll, AWS Lambda, and a handful of other tech to host a dynamic affiliate site for (basically) free.    Amazing stuff.

We thought about reading in ShareASale’s coupon feed for moving boxes for MovingCompanyReviews.com (if you’re looking for Chicago movers, Orlando movers, or movers in any other city check it out!), but punted b/c we found it too hard to be worth it.  Kudos to Steven for figuring it out!

 

 

Posted in Uncategorized | Leave a comment

Back in business helping Moving Companies

It’s been waaaaaaaaay to long since I’ve posted.   A lot’s happened since then.   Let me recap:

  • I took over as CEO of HomeFinder.com
  • We shut down MoverWebsites.com
  • At HomeFinder, we launched an internal startup called MovingCompanyReviews.com
  • I left HomeFinder.com to be CEO of EarthClassMail.com in 2015
  • I ended up buying MovingCompanyReviews.com from HomeFinder in 2016

Phew!   I am happy to report that MovingCompanyReviews.com is alive and well, and doing better than ever.   It’s a really great site to find mover – we verify every review with a moving receipt (called a bill of lading), so consumers can trust the reviews they read on site.   For example, check out our Boise, ID movers.   We don’t have a ton of reviews there yet, but Big Boy Movers is a quality company that treats people right.

We’ve got some great features coming out – including giving consumers free pizza on their move days.  Who doesn’t love free pizza?

We’ve also got some great free moving leads programs for movers, as well as a killer review collection product where movers can give free coffee to past customers, and a cool “recommended movers” page that gives top real estate agents free advertising and exposure.

More to come soon!

Posted in Uncategorized | Leave a comment

Bang that Gong Again

Time to bang the gong again, we’ve got a new MoverWebsites.com customer live!   If you need Huntsville Al Movers or Fayetteville TN Movers, then head on over to GeneralMovingServices.com.     General Moving Services serves the Huntsville Alabama and Fayetteville Tennessee areas.

Like all of our moving sites, visitors can get an instant online estimate without having to give up personal information.  We think that’s a pretty cool feature, hopefully it’s one that drives more business.

 

Posted in Uncategorized | Leave a comment

Read wikipedia content into your Ruby on Rails app

I am playing around with a new site that helps people find horses for sale, aptly named www.FindHorsesForSale.net.  I wanted to provide searchers some background on the particular horse breed they were looking at, so I decided to provide the first few paragraphs from the wikipedia page for that horse breed, and then link off to the full wikipedia page.  For example, see the content on the lower left of the paso fino horses for sale page.

After some searching around, I found the perfect tool – the wikipedia-client gem on github.   As Judge Smails from Caddy Shack would say, “top notch, top notch!”

Here’s some quick code:

      page = Wikipedia.find(horse_page_name)
Posted in Uncategorized | Leave a comment

How to import a lot of records into a Ruby on Rails application quickly

I stumbled across this today after hacking around for hours trying to figure out import hundreds of thousands of records into a sqlite database in minutes – https://github.com/zdennis/activerecord-import.   Super simple, and pure awesome.   Works for sqlite, postgres, and mysql.

Posted in Uncategorized | Leave a comment

The Kayak/Orbitz/Expedia for buying Moving Boxes online

Been hacking away the last couple weeks building an online price comparison search for moving box kits.   Check it out at www.MovingBoxSearch.com, the design has a ways to go, and we still have to add a bunch of providers, but it’s getting there.

We did manage to do one neat thing, we’ll buy $5 worth of Starbucks coffee for anyone who buys moving boxes through us.   Within an hour or two of buying his/her boxes, the person will get an e-giftcard in their email inbox from Starbucks for $5.   Who couldn’t use a little coffee on their move day?

Posted in Uncategorized | Leave a comment