Go back to the main page

Improve your QuickBooks/Ruby integration experience with the quickbooks-ruby-base gem



Code from screencast and tutorial is available on Github.

Real-world to gem

I was recently able to wrap up a pattern from my QuickBooks/Ruby consulting into a gem. The gem complements and extends the quickbooks-ruby gem. Let's see how.

Speed up QB integration.

  1. First, install the gem along with quickbooks-ruby.
  2. Don't forget to bundle install.
  3. Now you need to configure the persistent locations of the Intuit OAuth connection.
    • For example, if you are storing the token, secret, and company_id like this:
    •   account = Account.find(1)
    • Your config file might look like this.
    • This example comes from config/initializers/quickbooks.rb.
  4. Next, I am going fire up the rails console to further demonstrate.
  5. To create a quickbooks-ruby service takes only one line of code.
  6. The service method is available off the base object so you can quickly access query, create, and update.
    This one line saves 4 lines of code and is generic.
  7. There is a qr_model method that generates and initializes a quickbooks-ruby model, which are long to type out by hand.
  8. Before
  9. You can pass as many arguments to the model as it takes.
  10. This is an example of the email_address model.
  11. Lastly, the show method will return a "smart" array, customers in this example.
    • "Smart" because the DESC value returned adapts to which service is being shown. For example, if its the invoice service calling show, then the doc_number is displayed for DESC (for customer service its display_name).
    • The show method saves you from having type the following below and it is most useful for console usage.
    •  $ base.service.query.entities.map{ |e| "ID: #{e.id} DESC: #{e.display_name}" }
    • You can also pass the same options you would to the quickbooks-ruby query method e.g.
    •   $ base.show(page: 1, per_page: 150)
      The show alone method is worth installing the gem.


I want to keep the gem light weight but I would love to see pull requests coming from your QuickBooks/Ruby integration experiences. You can see the making of this gem in this 4 part series.