Category Archives: Ruby

How to make objects behave like ActiveRecords models…

…and make them usable with rails form helpers as well. 1.) Use ActiveModel Add to the top of your class in question. Now you have all the standard validations like at your hands. 2.) Make it possible to initialize your … Continue reading

Posted in rails, Ruby | Leave a comment

Why ruby predicate methods should return true or false and not something truthy or falsy

A rather long but interesting discussion on why ruby predicate methods should return true or false and not something truthy or falsy just because the language allows it: Rails pull request: request.xhr? now returns boolean as expected, rather than nil … Continue reading

Posted in Ruby | Leave a comment

Rails traps into which I fall every damn time

If the return value of a method in your tests is totally different from what you see in the source code, chances are 100:1 that you (or your colleague) stubbed it out before the test run You can’t set the … Continue reading

Posted in rails, Ruby | Leave a comment

Rails 3 and geokit

Or: A quick tutorial to get your application up and running with rails and geokit. Say you’re running a webapp which realizes where the user is located and offers this users the nearest yoga courses. Or the best deals in … Continue reading

Posted in Geokit, rails, Ruby | Leave a comment