0

This question is related to: How to link form after creating rails join table

I Had a products model, with a categories field, however needed each category in individual rows rather than the comma separated rows they were in. So I created a Category and ProductCategory model, and added all appropriate associations.

How do I link up the categories field from the old products model to the new Category table so that when a user enter a new product and adds the category, it will save to the category table.

Community
  • 1
  • 1
Yogzzz
  • 2,735
  • 5
  • 36
  • 56

1 Answers1

1

There is a great Railscast on setting up accepts_nested_attributes_for it should be just what you are looking for. I would do you a better service by just telling you to watch it, rather than replicate code.

http://railscasts.com/episodes/196-nested-model-form-part-1

Josh W Lewis
  • 1,319
  • 11
  • 19