I'm writing and app to let the production people estimate costs for building some products, they want to be able to give the product's base data (name of the product, client, etc) plus make the rec开发者_开发知识库ipe for it (which materials are needed in order to build it) in the same page, and I was wondering how do I save tabular data in my rails controller (ie. a products price, quantity, etc.) can It be done? Thanks
This is explained masterfully on railscasts #196, #197 and #198. Give them a look.
You would need a model for each item, with relationships between them all
so a model for Product and Materials
#app/model/product.rb
has_many :materials
#app/model/material.rb
belongs_to :product
and for products you could have your table setup with name, client_name, etc. For materials you could have the table setup as name, quantity, unit_cost, product_id
精彩评论