Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Why rails can't infer foreign key name automatically?
class Child < ActiveRecord::Base
belongs_to :parent # Child has parent_guid field
# ActiveModel::MissingAttributeError:
# can't write unknown attribute `parent_id`
end
class Parent < ActiveRecord::Base
self.primary_key = 'guid'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.