Hi @sb8244,
I get a warning when I try to do the migrations on page 97 with mix ecto.create
:
warning: invalid association
sms_messages
in schema PhoneApp.Conversations.Schema.Contact: associated schema PhoneApp.Conversations.Schema.SmsMessage does not have fieldcontact_id
lib/phone_app/conversations/schema/contact.ex:1
I wanted to ask if this is because of the following:
The “SmsMessage” module has a clause that says schema "sms_messages" do
. That is, the name of the module has the singular form, but the name of the schema is plural.
In case of the “Contact” module, the situation is reversed. It has an equivalent clause that says schema "contacts" do
.
My confusion starts here:
The “SmsMessage” module refers to the contact s via belongs_to :contact
(note the singular form in the token), while the “Contact” module refers to the SMS messages via has_many :sms_messages
(note the plural).
Do the tokens’ (:contact
, :sms_messages
) forms (singular/plural) need to agree with the words in the schema
clauses (i.e., schema "contacts" do
and schema "sms_messages" do
)?