What is the correct path for text_field in my view?

Hail Caesars!

I have the following text entry field in my view: <%=
text_field :order, :company_name %>

However, company_name doesn’t really reside in the orders table. It
resides in the “company” table, which belongs to order, as follows:
Order.company.company_name. This is where my controller method
correctly saves it to. I added the company_name field to my orders
table as a temporary measure so I wouldn’t get a method not found
error. Companies belong to orders and each order has one company.

How can I change “:company_name” in my text_field helper to correctly
reflect the correct relationship between Orders and companies (that
is, Order.company.company_name instead of order[company_name] )?

Companies belonging to orders, rather than orders belonging to
companies, is correct for the business logic of this application.

Thanks in advance for your help.

Take a look at fields_for:

Also it’s worth looking at the rails casts on advanced forms:

This might be useful too:

Kind Regards