Hi all, I am trying to integrate with a legacy database (that I didn''t build!) where the association between tables is a modified id. Here is the structure: Table: Products PK => ProductID ... # additional columns Table: Cart_Lines PK => CartLineID FK => ProductID #foreign key to product FK => CartID #foreign key to cart ... # additional columns Table: Cart PK => ID ... # additional columns The problem is that in the Cart_Lines table the ProductID column has the prefix ''DP-''. So, if the ID of the product is 123456 then the value of the foreign key in the Cart_Lines table would be ''DP-123456''. Here are a couple more examples Cart_Lines.ProductID Products.ProductID DP-746748 = 746748 DP-143445 = 143445 DP-233434 = 233434 I thought I could use a simple belongs_to option to create the association in my code, but this obviously does not work because I end up with SQL like this: SELECT * FROM Product WHERE (Products.ProductID = ''DP-234332'') LIMIT 1 I thought that finder_sql would be the way to go but belongs_to does not support it. I tried setting conditions in the belongs_to where I modified the ID with no success. Can anyone give me a suggestion how I can tell my model to modify the foreign_key before it tries to load the association? Or do I have to create some kind of workaround? Thanks Peer -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---