This example is about setting up a Recipe book. Recipes have multiple meta properties like their title, a brief description, instructions and the like. Each recipe of course needs ingredients and each ingredient needs quantities of that ingredient for the recipe. What we will be setting up is a relationship of Recipes to Ingredients through Quantities.
A recipe :has_many tags :through quantities. You can add ingredients dinamically in the recipe form. When unlinking an ingredient, it is not deleted, only the link.
Things you may want to cover:
-
Implementation in Rails 3 and 4. See branch rails 3.2.16
-
Using Cocoon gem
-
Use of Twitter bootstrap
-
Setting up models
-
Creating join relationships
-
Setting up the form code: nested form and partial
-
Voila!
git clone cd complex_forms_wtih_cocoon bundle install rake db:migrate rails s -p XXXX visit http:/localhost:XXXX/recipes
Follow process trough commits
-
ERB at branch master
-
SLIM at branch slim_version
-
HAML at branch haml_version