0

Working with legacy database here, can't change the tables.

Have two tables. Lets say User and Admin. They both have user_id which is a string, and the case varies between the tables. I can pull out records by doing donwcase but its a manual query with no fancy ActiveRecord assosiation goods

How can I connect the two models?

I know that you can supply lambda to has_one and belongs_to, except it is used to narrow down the search, not to replace the AR generated one.

I am considering creating views on those tables and lowering the user_id in them. That could work if I dont figure out how to get this going

Ruslan
  • 1,919
  • 21
  • 42
  • have you checked this https://stackoverflow.com/questions/25047920/rails-belongs-to-with-custom-column-name – m3characters Aug 10 '17 at 18:38
  • @MicaelNussbaumer yes. They had problems with the column names. I have an issue with `user_id` in `Admin` being `FooBar` and `user_id` in `User` being `FOOBAR` – Ruslan Aug 10 '17 at 18:53

0 Answers0