[Rails] Re: Working with Legacy database
Eric Anderson
eric at afaik.us
Tue Jan 4 19:03:21 GMT 2005
Eric Anderson wrote:
> class Foo < ActiveRecord::Base
> has_many :aliases, :dependent => true, :finder_sql => <<-SQL
> SELECT db1.bars.*
> FROM db1.bars
> WHERE db1.bars.foo = #{name}
> SQL
> end
>
> class Bar < ActiveRecord::Base
> belongs_to :domain, :finder_sql => <<-SQL
> SELECT db2.foos.*
> FROM db2.foos
> WHERE db2.foos.name = #{foo}
> SQL
> end
Slight typo. The above should be:
class Foo < ActiveRecord::Base
has_many :bars, :dependent => true, :finder_sql => <<-SQL
SELECT db1.bars.*
FROM db1.bars
WHERE db1.bars.foo = #{name}
SQL
end
class Bar < ActiveRecord::Base
belongs_to :foo, :finder_sql => <<-SQL
SELECT db2.foos.*
FROM db2.foos
WHERE db2.foos.name = #{foo}
SQL
end
Left bits of the real objects in there instead of my reduced example.
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050104/001f31e4/signature.bin
More information about the Rails
mailing list