Read my latest article: Announcing RailsDeveloper (posted Wed, 01 Sep 2010 17:01:00 GMT)

Sneaking Rails through the (Legacy) system

Posted by Robby Russell Fri, 14 Apr 2006 23:01:00 GMT

17 comments Latest by lfd@126.com Mon, 23 Aug 2010 07:38:12 GMT

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

...Jeremy posted his slides as well. :-)

Subscribe to my RSS feed Enjoying the content? Be sure to subscribe to my RSS feed.
Comments

Leave a response

  1. Avatar
    Rob Sanheim Thu, 20 Apr 2006 16:56:08 GMT

    Hey Robby,

    Is the code for this available anywhere?

  2. Avatar
    Rob Goodwin Sun, 30 Apr 2006 18:37:12 GMT

    has commenting been fixed yet?

  3. Avatar
    Fabio Akita Thu, 29 Jun 2006 21:06:36 GMT

    I have nothing against the Surrogate Key-only for Active Record but do you intend to support intelligent keys (as the username in a User model) or even composite primary keys? Many people seems to miss those.

  4. Avatar
    denis Mon, 11 Sep 2006 20:49:10 GMT

    intresting article! thnks

  5. Avatar
    travel reward credit card Wed, 27 Sep 2006 09:27:42 GMT
  6. Avatar
    ademco Wed, 10 Mar 2010 13:12:27 GMT

    Nice read mate! I have a problem though, I can’t seem to get your RSS feed to work right in google chrome, is it on my end?

  7. Avatar
    cameroon 2010 world cup jersevghfgh Mon, 31 May 2010 06:22:36 GMT

    rtyrty

  8. Avatar
    jordan XI Fri, 04 Jun 2010 05:49:02 GMT

    ert er

  9. Avatar
    nike air tailwind Fri, 04 Jun 2010 05:49:15 GMT

    yuiyu iyu

  10. Avatar
    radii straight jacket red nylon silver Thu, 10 Jun 2010 03:12:59 GMT

    ertert er

  11. Avatar
    adidas campus Thu, 10 Jun 2010 03:13:11 GMT

    trytr

  12. Avatar
    bastian schweinsteiger world cup jersey Fri, 11 Jun 2010 01:32:11 GMT

    uy i

  13. Avatar
    air max 360 ii Fri, 11 Jun 2010 01:32:23 GMT

    ty ut

  14. Avatar
    Louis Vuitton Wallets Mon, 19 Jul 2010 18:07:01 GMT

    Louis Vuitton Card Holder M61733 Louis Vuitton Card Holder Louis Vuitton Zipped passport cover M66501 Louis Vuitton Zipped passport cover Louis Vuitton Passport Cover M60181 Louis Vuitton Passport Cover Louis Vuitton Iphone case 3G M60114 Louis Vuitton Iphone case Louis Vuitton Phone Case MM M66546 Louis Vuitton Phone Case Louis Vuitton Pochette Tulum M60020 Louis Vuitton Pochette Tulum Louis Vuitton Cards Holder Pass M66541</ a> Louis Vuitton Cards Holder Pass Louis Vuitton cigarette case M63024 Louis Vuitton cigarette case Louis Vuitton Badge Key Holder M60048 Louis Vuitton Badge Key Holder Louis Vuitton Wapity Case M58030 Louis Vuitton Wapity Case

  15. Avatar
    bag factory Mon, 09 Aug 2010 03:46:36 GMT

    acts_as_legacy. For those not at Canada on Rails… I announced a small project that I’m going to be

  16. Avatar
    chanel bracelet Mon, 09 Aug 2010 06:51:57 GMT

    tyle resembles the extremely popular Bentley Motors . The Montbrillant Datora Windrider with a self-winding chronograph was specially designed for aviation. The Breitling Avenger developed in 1952 has an operational navigation computer.

  17. Avatar
    lfd@126.com Mon, 23 Aug 2010 07:38:12 GMT

    Keep posting stuff like this i really like it.Fleece Blankets, I would be extremely interested to hear more information on this. Plush Blankets,Cheers,Thanks for sharing I’ll email my friends about this too.Embroidered Blankets,I’m impressed! fleece throw,After reading your post I can tell you are well-informed about your writing.fleece throws, If only I had your writing ability. I look forward to more updates and will be returning.Cheers!

Share your thoughts... (really...I want to hear them)

Comments