Category Archives: Ruby

Debugging Cucumber Tests With Ruby-Debug

Today I ran into a scenario where I needed to step through some ruby code and examine the state of various objects in my rails app. I’ve used the ruby-debug gem a number of times to do exactly this. However, … Continue reading 

| Leave a comment

Making Mongoid Play Nice With Backbone.js

Backbone has some great features that make it dirt-simple to integrate with a Rails back end. For example, the Backbone models have a .fetch(), .save() and .destroy() method on them. These methods make a call back to your server, based … Continue reading 

Also posted in DomainDrivenDesign, NHibernate | 9 Comments

Partially Solving The Date Validation Deficiency Of Rails 3 And Mongoid 2 Models

A while back, I posted a question on stack overflow on how to properly validate a date input from a text field input, without throwing exceptions when the string provided is not a valid date. ┬áThe core of the problem … Continue reading 

Also posted in ASPNETMVC, DependencyInjection | 12 Comments

Using ActiveSupport::Notifications and ActiveSupport::Concern To Create An Audit Trail

In my previous post, I outlined a scenario that needs to be audited for HIPAA compliance – a patient with a list of medications. Every time a medication is added, updated or deleted, an audit record has to be created … Continue reading 

Also posted in DomainDrivenDesign | 21 Comments

How do you handle simple pub-sub, evented architecture in rails apps?

I’ve been asking this question in various forms, via twitter, for a few days now. I’ve received a number of answers from people and have spent some time talking with Jak Charlton about the patterns that I would have used … Continue reading 

Also posted in DomainDrivenDesign | 20 Comments

A Couple Of Tips For Ruby Code Blocks

Ruby’s code blocks (a.k.a “lambdas” or anonymous functions in .net) are powerful little tools that get used everywhere, and for good reason. But, every now and then I run into a little trick or issue related to them. For example: … Continue reading 

Also posted in AutoMapper | 5 Comments

Sometimes It’s Better To Use A Ruby Hash Than Create A Custom Class

The Eloquent Ruby book talks about the use of hashes and arrays vs classes. One of the things it covers is how hashes and arrays are often used by experienced ruby developers in place of custom classes. Coming from a … Continue reading 

Also posted in SQL | 17 Comments

Don’t Do Role-Based Authorization Checks; Do Activity-Based Checks

I’ve built a few dozen security mechanisms in my career. Unfortunately, I kept getting it wrong, hence the need to keep building them. Over the years, though, I learned a number of different ways that a security system can be … Continue reading 

Also posted in LINQ | 10 Comments

Mongoid: Polymorphic Find Or Create New On Embedded Document Collections

In the old v2.0.beta.20 version of Mongoid, I was able to call .find_or_create_by on an embedded document collection and pass a type as a second parameter to the method. This would allow me to create a document of a specific … Continue reading 

Also posted in Tools | 26 Comments

Re-learning The Meaning of ! in Ruby Methods

Hugo Bonacci has been tweeting a lot about the Eloquent Ruby book, so I decided to pick up a copy. In spite in my year or two of working with Ruby, I still feel like a n00b most of the … Continue reading 

Also posted in Refactoring | 6 Comments