I am using Ruby on Rails v3.2.2 and, after post my previous question, I would like to know and understand if (or not) to explicitly validate foreign keys related to ActiveRecord::Associations
is needed. For example:
class CategoryAssociation < ActiveRecord::Base
belongs_to :article, :foreign_key => 'article_id'
belongs_to :category, :foreign_key => 'category_id'
validates :article_id, :presence => true, :numericality => { :only_integer => true }
validates :category_id, :presence => true, :numericality => { :only_integer => true }
end
Are above validates
methods really needed? Why?