Adventures in Programming


I write about my programming challenges and successes

The Mysteries Of Ajax

Last week, I encountered a mysterious problem while building a ruby on rails application. I was trying to build a library application with a page where users can search for books. My page used a form_with to send a GET request to the results page (“/results”). The user input should be stored in the in the GET request, inside the parameter query. The get request should trigger the results method in my controller, which searches for data matching the user’s query and renders the results in a view template. That’s what should have happened, but instead, pressing the “submit” button did not change the appearance of the page at all. I coded my form_with like this:


Building a Better Birding App: My Attempts to Store a Whole Lot of Data

A couple weeks ago, I decided to recreate a simplified version of ebird, a website designed for birdwatchers to record sightings. I used the powerful Ruby gem Sinatra. In nontechnical terms, Sinatra essentially creates websites that can access and display data stored in tables on your computer. In this case, I had two tables – ”Birds” and “Regions” – which stored information about different bird species and the regions where they live.


Round and Round with Circular Imports

Since I started seriously programming three months ago, I’ve run into hundreds of problems with my code. I’ve come to see errors as completely normal, usually fixable with de-bugging techniques and not a cause for concern. However, there are, occasionally, problems I encountered that were less easy to understand and fix, problems that revealed fundamental misconceptions in my model of how code should work. In this blog post, I want to discuss a fundamental conceptual issue I encountered while designing a CLI application for accessing new music. For the sake of this post, all you need to know is that my program contained two classes defined in two separate files: the Artist class, and the Song class. I called methods from the Artist class inside the Song class and vice versa; as a result, each class needed to access the class methods and variables defined in the other. I thought I knew how to make this happen with a few well placed require relative statements.