I cant really wrap my head around how to do this since I’m new at RoR.I have a Price model which is the only table i want to use for forms. I want to have 2 other MVCs that are UserData and Search.
The scenario is Users can input Prices and these Prices have 3 places to go. It can be their Data area, Search area or both areas. But the twist is Data area will have my parts on the form like the category of price and same goes with the Search area, that form you can put tags on it.
So how do i set it up so i am using my Prices form for the other 2 MVCs?
EDIT:
User has_many Prices
UserData has_many Prices and Category belongs_to UserData
Search has_many Prices and Tag belongs_to Search
Price Form = price name, date, and cost only.
UserData + Price Form + Category model = price name,date,cost and category.
Search + Price form + Tag Model = price name,date,cost and tags of price ( vegetables, candy?)
Hi If you’re using rails 3 check
http://railscasts.com/episodes/269-template-inheritanceif older version you should create foldersharedunder your views directory and place there partial_price_formand render it on pagehttp://guides.rubyonrails.org/layouts_and_rendering.html– guide on renderingIf your have any connections between models please post its description
now how to have one form for several models
for better understanding I would advise you to check these 2 railscasts
http://railscasts.com/episodes/196-nested-model-form-part-1http://railscasts.com/episodes/197-nested-model-form-part-2also
http://stackoverflow.com/questions/5717421/accepts-nested-attributes-for-practical-form-use-for-in-rails-3may be helpful