views:

26

answers:

1

Let's say that you have a foreign key called COMPANY_ID in the table PERSON. In the model PERSON, can you write?

validates_presence_of :company_id

or

validates_presence_of :company

or

both?

Which is the preferred and why?

A: 

Prefere validates the foreign_key. It's better because there are no association made so 1 SQL request less.

shingara