Belongs_to, has_many relationship using other foreign key

I am creating a relationship between two tables and objects.

public_user
has_many :orders

orders

belongs_to :public_user

however I need to connect them using a foreign key other than the
public_user_id. Namely the customer_number field.

How do I code this in Ruby on Rails?

Thank you for your time in advance.

however I need to connect them using a foreign key other than the
public_user_id. Namely the customer_number field.

How do I code this in Ruby on Rails?

Look into the :foreign_key option to has_many/belongs_to. It allows
you to change the field used to join on.

-philip

Philip H. wrote:

however I need to connect them using a foreign key other than the
public_user_id. Namely the customer_number field.

How do I code this in Ruby on Rails?

Look into the :foreign_key option to has_many/belongs_to. It allows
you to change the field used to join on.

-philip

Thank a lot Philip I will check that route now.

Cheers,

Mitch