fernando
fernando

Reputation: 21

Association for different types of columns

I have two models:

Is it possible to make an association in such a case? Migration is an option, but I would rather avoid it.

Upvotes: 0

Views: 31

Answers (2)

Alif Jamaluddin
Alif Jamaluddin

Reputation: 518

Basically, it will works. But theoretically it is wrong, because the id is defined in integer, but you're using A_id as string in another place. It's kind of messed up of data type. Luckily, Ruby doesn't need you to cast the String to Integer. But you're advice to follow Ruby convention in model reference, which is using Integer.

Upvotes: 1

fernando
fernando

Reputation: 21

That was stupid - you just make an an association and it works.

Upvotes: 0

Related Questions