Last Updated: February 25, 2016
· ka8725

Rule to use presence belongs_to association

Do you know what to validate for presence if you have belongs_to association: association name or foreign key?

I mean what do you use?:

belongs_to :account
validates :account_id, :presence => true


belongs_to :account
validates :account, :presence => true

Use second variant!

This is an explanation why: