I have a Comment class with a :foreign_key of post_id in the Post class. class Comment < ActiveRecord::Base belongs_to :post, :class_name => "Post", :foreign_key => "post_id", :counter_cache => true belongs_to :author, :class_name => "User", :foreign_key => "author_id" end But my CreateComments migration does not define a database-level foreign key: class CreateComments < ActiveRecord::Migration d
{{#tags}}- {{label}}
{{/tags}}