Reputation: 6263
I'm developing Ruby on rails applications and my source data is mysql table that developed by other developer using PHP+Mysql 2 years ago, my rails application just need to read and query 5 tables inside old database system (no non modify), is this possibly?
if yes, how can rails can read the model if the table not using standard name convention
( I did some research previously and read about connection_ninja / octopus - easy database sharding, but I would like to give specific question incase one of you have some inputs / experience and want to share it), many thanks
Upvotes: 1
Views: 330
Reputation: 9443
If you create a model to match each table, you can use the following in the model:
class Product < ActiveRecord::Base
self.table_name = "PRODUCT" # table name for the model to use
self.primary_key = "product_id" # primary key of the table
end
Click here for more information about overriding naming conventions for legacy databases.
Upvotes: 1