Rename weight=>position, remove tag (will add in later)

This commit is contained in:
Tyler Renelle
2012-02-01 11:37:29 -05:00
parent 571325d61d
commit fd2b82cee0
4 changed files with 5 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ class HabitsController < ApplicationController
# GET /habits/new.json
def new
@habit = Habit.new
@habit.weight = Habit.maximum('weight') + 1
@habit.position = (Habit.maximum('position') || 0) + 1
respond_to do |format|
format.html # new.html.erb

View File

@@ -5,6 +5,8 @@ class Habit < ActiveRecord::Base
belongs_to :user
default_scope :order => 'position ASC'
# TODO set cron for this
def self.clear_done
Habit.where(:habit_type => Habit::DAILY).collect do |h|

View File

@@ -23,14 +23,6 @@
<%= 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>

View File

@@ -5,12 +5,11 @@ class CreateHabits < ActiveRecord::Migration
t.string :name
t.integer :habit_type, :default => 1
t.integer :score, :default => 0
t.text :notes
t.boolean :up, :default => true
t.boolean :down, :default => true
t.boolean :done, :default => false
t.text :notes
t.integer :weight, :default => 1
t.string :tag
t.integer :position, :default => 0
t.timestamps
end