Hello, hobo noobie here. I've gone through the Agility tutorial and
done quite a bit of searching but I can't seem to find an answer to
this problem. I'm working on an inventory/point of sale type
application. The models involved are Products, Orders, and a
ProductsOrders join. The join table has a quantity column and I can't
figure out how to allow the user to enter a quantity of products for
an order.
Here are the models:
(script/generate hobo_model_resource Product)
class Product < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
name :string
...
timestamps
end
has_many :product_orders
has_many :orders, :through => :product_orders, :accessible => false
...
end
(script/generate hobo_model_resource Order)
class Order < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
timestamps
end
...
has_many :product_orders
has_many :products, :through => :product_orders, :accessible =>
true
...
end
(script/generate hobo_model ProductOrder)
class ProductOrder < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
quantity :integer
timestamps
end
belongs_to :product
belongs_to :order
validates_presence_of :quantity
...
end
This gives me a nice form for adding Products to an Order through a
drop-down list on the New and Edit Order pages. After adding a
Product to an Order there should be a way to enter the quantity for
the ProductOrder records that will be created when I hit the Save
button.
Any help would be greatly appreciated!
Brian
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.