Skip to content

Commit

Permalink
added float for recipe ingredients
Browse files Browse the repository at this point in the history
  • Loading branch information
garrengotthardt committed Jun 22, 2017
1 parent dced89f commit 25a55aa
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_for(@recipe_ingredient) do |t| %>
<%= t.hidden_field :recipe_id, :value => params[:recipe_id] %><br>
<%= t.collection_select :ingredient_id, Ingredient.all, :id, :name, { prompt: "Choose an ingredient" }%><br>
<%= t.number_field :quantity, placeholder: 'Quantity' %>
<%= t.number_field :quantity, placeholder: 'Quantity', step: :any %>
<%= t.select :units, ['Cup(s)', 'Gram(s)', 'Kilogram(s)', 'Liter(s)', 'Mililiter(s)', 'Pound(s)', 'Ounce(s)', 'Pint(s)', 'Teaspoon(s)', 'Tablespoon(s)'], { prompt: "Choose a unit of measure" }%><br><br>

<%= t.submit "Add Ingredient to Recipe " %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/recipes/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<%= form_for(@recipe_ingredient) do |t| %>
<%= t.hidden_field :recipe_id, value: @recipe.id %><br>
<%= t.collection_select :ingredient_id, Ingredient.order(:name), :id, :name, { prompt: "Choose an ingredient" }%><br>
<%= t.number_field :quantity, placeholder: 'quantity' %>
<%= t.number_field :quantity, placeholder: 'quantity', step: :any%>
<%= t.select :units, ['cup(s)', 'gram(s)', 'kilogram(s)', 'liter(s)', 'mililiter(s)', 'pound(s)', 'ounce(s)', 'pint(s)', 'teaspoon(s)', 'tablespoon(s)'], { prompt: "Choose a unit of measure" }%><br><br>
<%= t.submit "Add Ingredient to Recipe", class:'btn' %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeIngredientQuantityToFloatInsteadOfInteger < ActiveRecord::Migration[5.1]
def change
change_column :recipe_ingredients, :quantity, :float
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170622141741) do
ActiveRecord::Schema.define(version: 20170622145933) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -26,7 +26,7 @@
create_table "recipe_ingredients", force: :cascade do |t|
t.bigint "recipe_id"
t.bigint "ingredient_id"
t.integer "quantity"
t.float "quantity"
t.string "units"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 25a55aa

Please sign in to comment.