Return of the Beer.new

// July 6th, 2008 // General ramblings, Ruby on Rails, Uncategorized

Yes that’s right, last month when I was visiting the Sydney Ruby on Rails monthly meetup I was introduced to the Beer model, not the type of model your thinking about, something more along the lines of:

class Beer < ActiveRecord::Base
  CAT_PISS = 2
  named_scope :drinkable, :conditions => ['quality > ?', CAT_PISS]
  # ...
end
 
Beer.drinkable
 
#=> [#<Beer id: 25, name: "Tooheys New", quality: 4, rating: 7.1, best_served: "cold">, 
#<Beer id: 17, name: "Corona", quality: 7, rating: 9.0, best_served: "cold with lime" >]

(Its a Rails thing)

3 Responses to “Return of the Beer.new”

  1. twe4ked says:

    If ‘beer’ == cold
    then ‘drink’
    else ‘put in fridge’
    EndIf

    If ‘beer’ == case > 1
    then BAAAADDD!!
    else fail…
    EndIf

  2. Syntactically speaking, your code is quite wrong.

  3. twe4ked says:

    Sudo code… Its not a language