BestMuni.com
http://bestmuni.com
This is my first web application designed for the iPhone. I wrote it because I was having trouble figuring out which direction I needed to walk from home to get the best bus or train to work. By pulling many different pieces of information from the NextMuni web service, BestMuni was able to give me all the information I need on one page. I used the google & yahoo geocoder on this project as well, to geocode all the muni stops to latitude and longitude. I also use the google maps API to display nearby lines.
Patches to rails
I've submitted many tickets & patches to rails. Here's a list:
-
Chaining scopes with similar :joins causes table aliasing errors
When performing an advanced search by chaining together named_scopes dynamically, I kept running into table aliasing issues. If more than one of my scopes joined in the profiles table, for example, MySQL would complain that the table was joined in more than once. There were many solutions to this problem, but the only way to keep these scopes completely independent of each other was to get ActiveRecord to remove the duplicate joins when combining the scopes. This patch simply combines multiple string identical joins into a single join. When two or more joins were specified in a scope, it also allows developers to write the joins in an array-of-strings, so that duplicates can be separated out and removed properly. Take a look at my article for more information.
Status: COMMITTED
-
Single query eager loading should be able to be globally disabled
Optimizing the performance of a data heavy application, I found myself constantly trying to fight with rails to trigger the multi-query eager loading process. When you :include tables, rails attempts to determine if you are using these tables in your :conditions, :order, etc. If you are, it falls back to a single SELECT query with lots of LEFT OUTER JOINs. If not, it executes one query for each table, which is much faster. The problem comes from when rails guesses wrong. The guessing process is just regular expressions, which aren't parsing SQL fragments perfectly, combined with the fact that it didn't check for tables in your :join clauses, lead to some very bad guesses on my project. Since I never reference :included tables in my SQL fragments, I wanted to globally disable them so that it would always guess right.
Status: WON'T FIX (community prefers to build better guessing)
-
f.label should be able to target f.radio_button
The IDs generated by the radio_button method on a FormBuilder can't be targets by the label method. Radio buttons almost always need labels, and those labels need to target the correct radio button to be functional. Unfortunately, the radio button IDs use the radio_button's value in them, and there's no way to make the label method generate a corresponding "for" attribute. I simply made it possible to pass :value => "something" to the label method and have it generate the same ID that a radio_button would.
Status: PATCH SUBMITTED
-
f.radio_button generates the wrong ID if inside fields_for with :index
After trying to build a view solution for nested assignment using fields_for, I realized that the IDs generated by f.radio_button do not include the :index of their parent fields_for (unlike every other form helper). This is because the code to generate the ID for a radio_button is special because it includes the value at the end. I simply refactored this code to build on existing ID generating logic and add the value suffix at the end.
Status: PATCH SUBMITTED
-
association#find has redundant option merging logic with scope merging
I'm trying to make associations chainable. Post.first.author.groups.members, for example, should give you all the people in the groups that the author of this post is in. Along the way to this goal, I noticed that the #find method of an association_collection does its own merging of find parameters like :order and :conditions. In this ticket, I'm hoping to convert #find to using
@reflection.klass.scoped(something).find(*args).Status: TICKET SUBMITTED