Forum: Ruby on Rails (Nested) collection in a view

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ddffdd431166f9abb724004bdbe56f8c?d=identicon&s=25 Lucifron (Guest)
on 2006-03-13 15:45
(Received via mailing list)
Say I have a model consisting of Order( has_many :order_lines) and
OrderLine(
belongs_to :order).

What would be the 'rails way' to create an order form?

Know I could just say @order = Order.some_order, @lines =
@order.order_lines, and use something like this..:

order.rhtml:
Order no: <%= @order.no %>
Date <%= date_select "order", "date" %>
<hr />
<% for line in @lines %>  # or use a partial..
  ...
  Amount: <%= text_field "lines[]", "amount" %>
<% end %>

..then add the lines to my Order in the controller.

I feel though, that I should be creating my whole order with
Order.new(params[:order]). Is that feasible/possible/the right way?

If possible, please show me how i would call text_field with
@order.order_lines.amount -- or what the id/name fields should be if I
have
to write the input tag by hand.

--
View this message in context:
http://www.nabble.com/%28Nested%29-collection-in-a...
Sent from the RubyOnRails Users forum at Nabble.com.
This topic is locked and can not be replied to.