I’ll be posting stuff in the next few days about acts_as_legacy. For
those not at Canada on Rails. I
announced a small project that I’m going to be working on.
Acts as Legacy!
Here are my slides… up til I tried to do a live demo. ;-)
# Inventory model
class Inventory < ActiveRecord::Base
acts_as_legacy :table_name => 'inventory',
:primary_key => 'prod_id',
has_one :product, :foreign_key => self.primary_key
column_alias :quan_in_stock, :stock
end
Let’s try something a little different…
# SalesPerson model
class SalesPerson < ActiveRecord::Base
acts_as_legacy :table_name => 'sales_person',
:primary_key 'sales_p_id',
:column_alias => 'sales_p_'
validates_presence_of( :name, :email, :phone )
end
# usage....
SalesPerson.find( 7 ).sales_p_name
=> 'Nigel'
SalesPerson.find( 7 ).name
=> 'Nigel'
The Slideshow
- Sneaking Rails through the (Legacy) System (quicktime)
- Sneaking Rails through the (Legacy) System (flash)
…Jeremy posted his slides as well. :-)