System Tools to Debug Rails

Want to share this amazing link.  Was having an issue yesterday with a silent failure of a rails app- no error message, no server logs.  The browser just kept waiting for a response from the app.  I suspect the issue had something to do with a gem, and a bundle update fixed the issue.  But while I was looking for resources, I found this:  Debugging Rails with Operating System Tools.

Deconstructing the qbo_api gem

I recently built a CSV parser and Quickbooks importer using the qbo_api gem.  The documentation for the gem was not easy for me to understand, but I was able to hack the functionality I needed into the sample Sinatra app that’s provided with the gem.

I now want to create another Quickbooks import tool and use it with a rails app that I’ve already built.  The trouble is figuring out how to set up a rails app to use the qbo_api gem.  There are no explicit instructions on how to do this in the gem’s documentation.

After a few hours of hacking around last night with a buddy, I have a slightly better understanding of what’s going on under the hood with the gem.

Looking at the example app provided with the gem, you can see from the require statements that there are a few other gems required:  omniauth and omniauth-quickbooks.  Omniauth-quickbooks is a strategy for omniauth to connect to quickbooks, specifically.

Lines 19-21 of the example app tell Sinatra to use the omniauth-quickbooks strategy, with tokens that are stored in the .env file.  Lines 31 – 36 set up the index page of the app, where you connect to quickbooks:

qbo-apiQboApi::APP_CENTER_BASE is a url where some Quickbooks JavaScript is hosted:  ““.  This is used in a script src tag on index.erb which loads the Quickbooks javascript library for connecting the api.  oauth_data is a method that returns a hash with oauth tokens.


In the hash, consumer_key and consumer_secret are constants, pulled from the .env file when the app loads.  But the token, token_secret, and realm_id are pulled from the session.  When the index page is first loaded, these haven’t been saved to the session yet.

The assignment to the session happens in the last route, starting at line 64:

get authThis method is called from index.erb, which is mainly two javascripts, explained here.

I haven’t yet figured out what env[“omniauth.auth”][:credentials] are, but I assume it is created by the omniauth gem and holds the tokens returned from Quickbooks when you connect.

Water Monitoring Database

I built a Rails App that could be used by environmental groups to monitor water quality.  It uses the Google Maps API.  Users can create locations by entering GPS coordinates, or by clicking on a map.  Clicking a location on the map automatically enters the GPS coordinates into the form.  It also has different custom map icons depending on the type of location.


This project took about 8 hours all told.  It uses Devise for authentication and Bootstrap for the layout.  Feel free to check out the public version on heroku.  You will need to create an account in order to add locations.

Using JavaScript in Rails

I’ve been busy the past few months with a contracting gig, so my blogging has suffered. I’ve learned a lot, especially about using JavaScript and Ajax in a rails app. I’m just going to leave this link here for now:  Rails with no JS Framework.

I’m currently seeing no point in using a JavaScript framework on top of a Rails app, with all the functionality that’s built into Rails.  Of course my opinion on that might change over time.

Installing Linux Mint on VirtualBox, on a Windows 10 Laptop

So last month my trusty old Windows 7 laptop (which I grabbed at a great price right when Windows 8 was getting pushed out) died, or at least the monitor did.  My life situation was a little hectic and I needed a laptop fast.  So I rushed out and bought a new one.

I’ve still been using the old laptop for rails development, dual booting Ubuntu, just plugged into a monitor. Meanwhile I’ve been trying to set up Virtual Box to run linux on the new laptop, with a good deal of trouble.

I was finally able to get Linux Mint running, after several hours spread out over a month.  It turns out that I had to follow these instructions to allow any virtual machine to run.  Once that was done, installation was relatively straightforward.

I’ve been struggling with VirtualBox ever since I started learning rails.  I’m excited to start playing around with it now!

React with Rails

I’ve been interested in putting a javascript framework on the front end of a rails app for a while now.  After working through this tutorial, React seemed like the obvious choice.

It’s simple and clean.  With the react-rails gem installed, all you have to do is write some javascript or coffeescript.  No erb, no handlebars, just javascript.  So simple!

I added a view with some basic add, edit and delete actions to the rails app I built for work.  The main problem is that there are none of the rails view helpers, so I am having a problem with figuring out how to implement a select box in coffeescript, and how to deal with associations, so this new view is not ready for production but I hope to get it going soon.

Learning C the Hard Way

I’ve been kind of scattershot in my learning lately.  I’ve been unsure as to what direction I should go.  I’ve dabbled in Angular and Meteor.  I tried a C++ course through Coursera and downloaded Visual Studio but I was turned off by the massive download and new environment.

I went to Meteor Spacecamp this weekend.  I’ve been working on new features for the app I built for work.  I’ve been thinking through a new app for work and made a couple of tries at that.  I’ve also been trying to deploy an existing app as a volunteer project.  That one’s hard.

As far as learning goes, I’ve decided to settle on learning C for now.  I know it’s a language that will be replaced by Rust or some other language and there’s no real reason to write code in it, but it seems like a good opportunity to get a deeper understanding of how code works in general.  Ruby is written in C.  So is PHP.

So I’ve started Zed Shaw’s Learn C the Hard Way, and I’m really liking it!  I’m up to chapter 15 on pointers.  I plan on completing this before I move on to something else.

The MEAN Stack for Rubyists

I’ve been hearing about the MEAN stack for a long time now.  I heard what it stands for:  Mongodb, Express.js, Angular, and Node.  I also heard that it was roughly analogous to the LAMP stack (Linux, Apache, MySQL, and PHP).

Even after learning JavaScript and Angular, and using Mongodb a few times, I still didn’t quite understand the MEAN stack.  But this morning I read this excellent article that laid it out in a way I understood instantly.

Mongodb is the database

Express.js is a framework like  Sinatra

Angular is the templating framework (like erb)

Node is the server

NPM is like Bundler.

Easy enough!

Brakeman and Rails Security

I had the chance to listen to this talk today:

It’s very good.  On my way home from work, I listened to a Ruby Rogues podcast on Brakeman.  So, naturally when I got home I installed Brakeman and ran it on my reporting app.

I’m happy to report that the only vulnerabilities reported were due to the version of rails I used, and not my code.  But then, after watching the video, I wonder what that’s worth?