From 571325d61d622086523bb520eeea4d1e89b1105d Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 1 Feb 2012 11:16:12 -0500 Subject: [PATCH] Adding weight & tag --- app/controllers/habits_controller.rb | 3 ++- app/views/habits/_form.html.erb | 8 ++++++++ db/migrate/20120201040610_create_habits.rb | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb index 090c774ded..2e5ff7862e 100644 --- a/app/controllers/habits_controller.rb +++ b/app/controllers/habits_controller.rb @@ -18,7 +18,8 @@ class HabitsController < ApplicationController # GET /habits/new # GET /habits/new.json def new - @habit = Habit.new(:user_id => current_user.id) + @habit = Habit.new + @habit.weight = Habit.maximum('weight') + 1 respond_to do |format| format.html # new.html.erb diff --git a/app/views/habits/_form.html.erb b/app/views/habits/_form.html.erb index a5b4a55b8b..89f0f40fc6 100644 --- a/app/views/habits/_form.html.erb +++ b/app/views/habits/_form.html.erb @@ -23,6 +23,14 @@ <%= f.label :notes %>
<%= f.text_area :notes %> +
+ <%= f.label :weight %>
+ <%= f.text_field :weight %> +
+
+ <%= f.label :tag %>
+ <%= f.text_field :tag %> +
<%= f.submit %>
diff --git a/db/migrate/20120201040610_create_habits.rb b/db/migrate/20120201040610_create_habits.rb index a958e62cd8..37f671a668 100644 --- a/db/migrate/20120201040610_create_habits.rb +++ b/db/migrate/20120201040610_create_habits.rb @@ -9,6 +9,8 @@ class CreateHabits < ActiveRecord::Migration t.boolean :down, :default => true t.boolean :done, :default => false t.text :notes + t.integer :weight, :default => 1 + t.string :tag t.timestamps end