What is the App Engine Gem
I really like working with the Ruby team at Google. One of our goals is to give the community tools and products that are easy to use. Awareness of the Ruby community, and all of our delightful quirks, isn’t high at Google. So as a team, we spend part of our time advocating for our Ruby community and teaching Googlers about the joys of Ruby. We also spend some time coming up with creative ways to reach our community’s unique needs.
One of those creative solutions is the App Engine gem. The App Engine gem provides a set of tools that make it easier to use App Engine with Ruby and especially with Rails. It isn’t that it is hard to use App Engine with Rails, we know folks are doing it already. In fact, I’ve used it for some of my projects, but we knew we could do better.
The first thing the App Engine gem provides is automatic Stackdriver integration for Rails Applications. For most language communities having to do your own configuration and authentication to get things like logging and crash reporting isn’t a big deal. Rails supports “no code required” integrations for third-party libraries through railties. This means when you use the App Engine gem you don’t have to do anything other than add the gem to your Gemfile and the rest of the initialization is taken care of for you.
To Rubyists, this seems normal but when I was writing my blog post on Ruby and Stackdriver one of the reviewers asked: “where’s the setup code?” I told them that you didn’t need any and they were astonished. Sometimes I forget how awesome Ruby and Rails are for lazy developers like myself.
The other main thing that the App Engine gem gets you is a way to run application commands against the production environment. When we released App Engine for Ruby in spring one of the most common questions we got was “but how do I run migrations?” At that point, the recommended way to do it was to connect your local environment to the production database and run the rake commands locally. This was something I did a lot back in 2007 when I was first using Rails. I knew it was a bad idea back then, but lots of folks did it. As we’ve matured as a community, we’ve, correctly, moved away from solutions like this, to the point that many current Rails developers don’t even know that you can do this.
The App Engine gem gives you rake appengine:exec -- [your command here]
so that you can run things like migrations and other rake tasks on your production instance. The examples on our Ruby landing page have been updated to use this tool, so you no longer have to connect your local development environment to production. And yes, we know the original plan wasn’t a great idea, which is why we’ve released this gem to make things work the way the Ruby community works.
If you are using App Engine either for work or for side projects, I encourage you to check out the App Engine gem.