rubyonrailsin

A Ruby and Rails talk

Saturday, March 20, 2010


[Rails] what is the correct path for text_field in my view?

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive