diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb index 2e5ff7862e..ce98500714 100644 --- a/app/controllers/habits_controller.rb +++ b/app/controllers/habits_controller.rb @@ -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 diff --git a/app/models/habit.rb b/app/models/habit.rb index 69640c81ac..14a2cec3c4 100644 --- a/app/models/habit.rb +++ b/app/models/habit.rb @@ -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| diff --git a/app/views/habits/_form.html.erb b/app/views/habits/_form.html.erb index 89f0f40fc6..a5b4a55b8b 100644 --- a/app/views/habits/_form.html.erb +++ b/app/views/habits/_form.html.erb @@ -23,14 +23,6 @@ <%= 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 37f671a668..3c4d1a73aa 100644 --- a/db/migrate/20120201040610_create_habits.rb +++ b/db/migrate/20120201040610_create_habits.rb @@ -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