Created
December 29, 2011 01:58
-
-
Save bradylove/1531122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .well | |
| = form_for @recipe do |f| | |
| -if @recipe.errors.any? | |
| .errorExplanation | |
| = pluralize(@recipe.errors.count, "error") | |
| prohibited you from creating the recipe. | |
| %ul | |
| - @recipe.errors.full_messages.each do |msg| | |
| %li | |
| = msg | |
| %fieldset | |
| %legend | |
| = @legend | |
| .clearfix | |
| = f.label :title | |
| .input | |
| = f.text_field :title | |
| .clearfix | |
| = f.label :difficulty | |
| .input | |
| = f.collection_select :difficulty, Recipe::DIFFICULTIES, :to_s, :humanize | |
| .clearfix | |
| = f.label :prep_time | |
| .input | |
| = f.collection_select :prep_time, Recipe::TIMES, :first, :last | |
| .clearfix | |
| = f.label :cook_time | |
| .input | |
| .clearfix | |
| = f.label :ingredients | |
| .input | |
| .clearfix | |
| = f.label :directions | |
| .input | |
| = f.text_area :directions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Recipe | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| include Mongoid::Paranoia | |
| field :title | |
| field :cook_time, type: Integer | |
| field :prep_time, type: Integer | |
| field :ingredients, type: Hash | |
| field :directions, type: Array | |
| field :estimated_cost, type: Integer | |
| field :difficulty | |
| field :menu # Breakfast Dinner Lunch etc etc | |
| belongs_to :user | |
| belongs_to :food_type | |
| TIMES = { 5 => "5 Minutes", | |
| 10 => "10 Minutes", | |
| 15 => "15 Minutes" } | |
| DIFFICULTIES = %w{ easy medium hard } | |
| def total_time | |
| cook_time + prep_time | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment