Category Ruby


Follow directions here…   Setting Up Octopress Had one hiccup in my system didn’t have Ruby 1.9.2 which .rvmrc file requires ( I had to go ahead and install it.   Deploying on Heroku:   That all went fairly well… though I didn’t understand all the intermediate steps. I’ll have to take closer […]

Procs and lambdas

You know how everything in Ruby is an object, well, as it turns out that’s not quite true. Ruby blocks are not objects! So, blocks are not objects, but you can turn them into objects without too much trouble. We do this by wrapping our block in an instance of the Proc class… PROCS: Very standard to pass along a code block […]

=== case equality operator

In a case statement… case number when 5 #some code when 3 #more code else #something else end Behind the scenes 5 is being compared to number with the === operator, so 5 === number, 3 === number, etc   several = { |number| number > 3 && number < 8 } none = […]

The tap method

I haven’t found great explanations for this yet but there is a video below… The tap method is available to all Ruby objects and serves as a way to have a block “act on” the method’s caller and return the object called. Per the Ruby docs, “the primary purpose of this method is to ‘tap […]

Stack Level Too Deep Error

This error generally happens when you accidentally recursively changing an attribute. If you have a username attribute in User model, and a virtual attribute named username, that is directly changing the username, you end up calling the virtual, the virtual calls the virtual again and so on.. Therefore, take a look on whether something like […]

Ruby Collections and Enumerators – David Black

Ruby Collections and Enumerators David Black June 26, 2012 Enumerators – what is an enum? – an instance of class Enum -external iterator -iterates via a specific method on an underlying object ??next method- walk through the iteration and give you the next value the default bound is the each method %w –> converst to […]


Sinatra Book, it’s a quick read: Seem like a really simple version of Rails– A rack based application with lots of common features in terms of routing, filters, ERB…   Here’s a screencast on Sinatra: (free) There is a peepcode on Sinatra: ($) Another paid one here: ($)