Apr 16, 2014 · 1 minute read
Check out my recent article on thoughtbot’s blog.
Frequently on projects we need to run a calculation through an ActiveRecord association. For example, we might want to get a user’s all time purchases, a company’s total amount of products sold, or in our case, the total amount of loans made to a campaign. This sort of calculation is ripe for using a map and an inject but frequently the solution is more elegant and faster if we can have SQL do the work instead.
Read On →
Mar 25, 2014 · 1 minute read
This post is on the softer side of things. I was working on a Ruby exercism this morning alone in a coffeeshop and was just not getting anywhere. The problem was simple enough:
Write a function to convert from normal numbers to Roman Numerals However trivial the problem was I was just spinning my wheels. It must have been an off day. I ended up with a mess of if statements that was seemingly leading nowhere.
Read On →
Feb 14, 2014 · 4 minute read
Meet FreshFinder. FreshFinder is a location aware website that allows you to explore farmers’ markets across the US. Data is sourced from the USDA and presented in a beautiful map-based interface. The full application architecture can be seen here. The code is available under the FreshFinder organization on GitHub. The site is pretty zippy but we had to do some work to get it that way. Here’s the story.
Read On →
Feb 6, 2014 · 6 minute read
For our last project, my team built a real time dashboard for development teams so managers and team members can have an at a glance look at what’s happening in a project. A user can create a project and link up Github repos, Pivotal Tracker Projects, Travis CI builds, and Code Climate scores. We built the app using a Services Oriented Architecture and learned quite a bit along the way.
Read On →
Jan 23, 2014 · 5 minute read
Editing on the server You know that terrible feeling you get when you’re editing code on the production server? Wouldn’t it be nice if we could easily deploy code from our command line to our VPS? Our most recent project was deployed to a VPS on Digital Ocean and having come from a lot of experience deploying to Heroku, we had to script out our deploy pipeline by hand. It was a fun learning experience ripe with seemingly undebuggable pitfalls.
Read On →
Jan 10, 2014 · 3 minute read
I was building a model recently to support a form where users can create events with a given day and time. I was experimenting with using Postgres’ range data types and needed to parse the user input from many fields into a single tsrange (timestamp range) field. Using attr_accessors got me most of the way there but I learned some interesting things about how ActiveRecord casts data types before validation.
Read On →
Dec 31, 2013 · 2 minute read
The Range Data Type Postgres 9.2 and later supports range data types including:
int4range — Range of integer int8range — Range of bigint numrange — Range of numeric tsrange — Range of timestamp without time zone tstzrange — Range of timestamp with time zone daterange — Range of date and as of Rails 4.0.0 in pull request 7345 so does Rails. Some of the commentary on this PR about bounds is interesting if you have some time to kill.
Read On →
Dec 11, 2013 · 4 minute read
Whenever you learn a new word, you inevitably see that word in the newspaper a day later. You’ve been seeing that word all along you just didn’t know it was there. I had a similar experience with programming yesterday when Ruby, Javascript, and functional programming concepts (by way of Clojure and Ruby lambdas) all came together. It was an exciting day…
###Javascript and Ajax I took my first deep dive into javascript a couple weeks ago doing exercises on exercism.
Read On →
Dec 5, 2013 · 3 minute read
Our most recent project is to extend our previous project using another team’s codebase. One of the first things we did was run the tests. We were greeted with a mess of ActiveRecord and view rendering logs. Oh man, this last team did some strange stuff, we thought.
We were expecting to see some pretty green (and red) dots but instead the terminal output looked like this:
$ rake test_all ActiveRecord::SchemaMigration Load (1.
Read On →
Nov 17, 2013 · 4 minute read
A recent project required an admin user to be able to upload images. Using paperclip we got the uploading going in no time. But, having the uploads going through the app server was very slow (~1.5s requests) so we moved the uploading into a background job. Having never messed with background jobs before I chose to use delayed_paperclip as an easy way to wade into the topic.
Using delayed_paperclip is appealing because it will solve our problem and teach us about background jobs all without having to write custom code.
Read On →