diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index f93af164..bcbd9326 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -14,7 +14,7 @@ class TodoController < ApplicationController @page_title = "List tasks" @projects = Project.find_all @places = Context.find_all - @shown_places = Context.find_all_by_hide( 0, "id ASC" ) + @shown_places = Context.find_all_by_hide( 0, "name DESC") @hidden_places = Context.find_all_by_hide( 1 ) @done = Todo.find_all_by_done( 1, "completed DESC", 5 ) diff --git a/tracks/app/models/context.rb b/tracks/app/models/context.rb index 44526134..cb7eec1f 100644 --- a/tracks/app/models/context.rb +++ b/tracks/app/models/context.rb @@ -5,4 +5,5 @@ class Context < ActiveRecord::Base # and must be less than 255 bytes validates_presence_of :name, :message => "context must have a name" validates_length_of :name, :maximum => 255, :message => "context name must be less than %d" + validates_uniqueness_of :name, :message => "already exists" end diff --git a/tracks/app/models/project.rb b/tracks/app/models/project.rb index 96dc94aa..0d4588d9 100644 --- a/tracks/app/models/project.rb +++ b/tracks/app/models/project.rb @@ -5,4 +5,5 @@ class Project < ActiveRecord::Base # and must be less than 255 bytes validates_presence_of :name, :message => "project must have a name" validates_length_of :name, :maximum => 255, :message => "project name must be less than %d" + validates_uniqueness_of :name, :message => "already exists" end diff --git a/tracks/app/models/todo.rb b/tracks/app/models/todo.rb index b9c1721b..07de183c 100644 --- a/tracks/app/models/todo.rb +++ b/tracks/app/models/todo.rb @@ -1,6 +1,6 @@ class Todo < ActiveRecord::Base - belongs_to :context + belongs_to :context, :order => 'name' belongs_to :project # Description field can't be empty, and must be < 100 bytes diff --git a/tracks/app/views/context/edit.rhtml b/tracks/app/views/context/edit.rhtml index 9d47fefb..37a97497 100644 --- a/tracks/app/views/context/edit.rhtml +++ b/tracks/app/views/context/edit.rhtml @@ -1,5 +1,6 @@