No - it doesn't automatically do any validation in rails, and it doesn't add any database validations either.
If you wanted you could validate it yourself:
class Task < ActiveRecord::Base
belongs_to :group
validate :group_exists?
def group_exists?
!!self.group_id && Group.exists?(:id => self.group_id)
end
end
There are gems which can help with this, and you can also use validates_presence_of :group
. See this SO question for more discussion:
validates_presence_of with belongs_to associations, the right way