diff --git a/app/models/bike.rb b/app/models/bike.rb index 4389ffb..9c253a1 100644 --- a/app/models/bike.rb +++ b/app/models/bike.rb @@ -2,10 +2,11 @@ class Bike < ActiveRecord::Base acts_as_loggable attr_accessible :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height, :top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_status_id - + has_many :transactions has_one :owner, :class_name => 'User' + has_one :task_list, :as => :item, :dependent => :destroy belongs_to :bike_brand belongs_to :bike_model belongs_to :bike_style diff --git a/app/models/task.rb b/app/models/task.rb new file mode 100644 index 0000000..4a1a5a0 --- /dev/null +++ b/app/models/task.rb @@ -0,0 +1,9 @@ +class Task < ActiveRecord::Base + attr_accessible :task, :notes, :done + + belongs_to :task_list + + def to_s + self.task + end +end diff --git a/app/models/task_list.rb b/app/models/task_list.rb new file mode 100644 index 0000000..66781b5 --- /dev/null +++ b/app/models/task_list.rb @@ -0,0 +1,10 @@ +class TaskList < ActiveRecord::Base + attr_accessible :item_id, :item_type, :name + + belongs_to :item, :polymorphic => true + has_many :tasks + + def to_s + self.name + end +end diff --git a/db/migrate/20130209022259_task_list.rb b/db/migrate/20130209022259_task_list.rb new file mode 100644 index 0000000..f59103b --- /dev/null +++ b/db/migrate/20130209022259_task_list.rb @@ -0,0 +1,9 @@ +class TaskList < ActiveRecord::Migration + def change + create_table :task_lists do |t| + t.integer "item_id", :null => false + t.string "item_type", :null => false + t.string "name", :null => false + end + end +end diff --git a/db/migrate/20130209023110_task.rb b/db/migrate/20130209023110_task.rb new file mode 100644 index 0000000..16c44d1 --- /dev/null +++ b/db/migrate/20130209023110_task.rb @@ -0,0 +1,10 @@ +class Task < ActiveRecord::Migration + def change + create_table :tasks do |t| + t.integer "task_list_id", :null => false + t.string "task", :null => false + t.text "notes" + t.boolean "done" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index f76382c..8baa56c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130120142249) do +ActiveRecord::Schema.define(:version => 20130209023110) do create_table "bike_actions", :force => true do |t| t.string "action", :limit => 128, :null => false @@ -96,6 +96,19 @@ ActiveRecord::Schema.define(:version => 20130120142249) do add_index "logs", ["loggable_id", "loggable_type", "context"], :name => "index_logs_on_loggable_id_and_loggable_type_and_context" + create_table "task_lists", :force => true do |t| + t.integer "item_id", :null => false + t.string "item_type", :null => false + t.string "name", :null => false + end + + create_table "tasks", :force => true do |t| + t.integer "task_list_id", :null => false + t.string "task", :null => false + t.text "notes" + t.boolean "done" + end + create_table "transaction_actions", :force => true do |t| t.string "action", :limit => 128, :null => false t.datetime "created_at", :null => false