Browse Source

Added TaskList and Task migrations and models

denney-disable-on-select
Jason Denney 12 years ago
parent
commit
545c33b953
  1. 3
      app/models/bike.rb
  2. 9
      app/models/task.rb
  3. 10
      app/models/task_list.rb
  4. 9
      db/migrate/20130209022259_task_list.rb
  5. 10
      db/migrate/20130209023110_task.rb
  6. 15
      db/schema.rb

3
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

9
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

10
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

9
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

10
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

15
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

Loading…
Cancel
Save