1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.