Reputation: 21
I have two models:
id
field (which is integer) A_id
- it is a string, but in fact a "foreign key" to the A. The values match, so technically all I need is to cast it.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
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