I have an order entry-like system where we know most of the time we'll need to use most items in the product catalog. The models are:
class Product < ActiveRecord::Base
hobo_model
fields do
name :string
end
end
class Order < ActiveRecord::Base
hobo_model
fields do
ship_to :text
end
has_many :order_lines
end
class OrderLine < ActiveRecord::Base
hobo_model
fields do
quantity :integer, :null => false, :default => 0
end
belongs_to :product
belongs_to :order
end
In the controller, I'm doing:
class OrdersController < ApplicationController
hobo_model_controller
auto_actions :all
def new
hobo_new do
Product.all.each do |product|
@order.order_lines.build :product => product
end
end
end
end
When rendering new.dryml, it's as if the order lines didn't exist. We know the number of products (3) and we know we want a line for each of them. There's more backend code that'll eliminate the rows which have 0 quantity.
How do I make it so the form opens with a row per product being on-screen?