Answer the question
In order to leave comments, you need to log in
Is it possible to rename a foreign key?
Is it possible to remove the prefix _id
from a foreign key?
New table. two models Order
andProduct
class Order < ApplicationRecord
has_many :products
end
class Product < ApplicationRecord
belongs_to :delivery, :class_name => "Order"
end
t.integer :delivery, index: true
ActiveRecord::AssociationTypeMismatch: Order(#85313090) expected, got 1 which is an instance of Fixnum(#73138750)
Answer the question
In order to leave comments, you need to log in
It is possible through foreign_key, but why does delivery_id not suit you?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question