Simple SQL query from a legacy db

You can override a lot of the defaults from ActiveRecord in order to work with legacy databases, so that you can perform something like the above with ActiveRecord.

class MyTable < ActiveRecord::Base
set_primary_key “my_key_name”

set_table_name “my_table_name”

end

See http://wiki.rubyonrails.com/rails/pages/HowToUseLegacySchemas for more examples.

If your rails app and this model use entirely different databases. See the comments on this post for more on that (there may be a better reference but this is the best 2 minutes with google pulled up):

http://blog.amber.org/2005/06/30/lost-in-multiple-rails/

James.

[...]

You can override a lot of the defaults from ActiveRecord in order to
work with legacy databases, so that you can perform something like
the above with ActiveRecord.

class MyTable < ActiveRecord::Base
    set_primary_key "my_key_name"
    set_table_name "my_table_name"
end

Seehttp://wiki.rubyonrails.com/rails/pages/HowToUseLegacySchemasfor
more examples.

[...]

Thank you for the link :slight_smile:

-Thufir