Adding weight & tag
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -23,6 +23,14 @@
|
||||
<%= f.label :notes %><br />
|
||||
<%= f.text_area :notes %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :weight %><br />
|
||||
<%= f.text_field :weight %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :tag %><br />
|
||||
<%= f.text_field :tag %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user