I am setting this up, in this way, so that we have some extensibility. We may wish to have some sort of a polymorphic association where multiple models need to have a scheduling model available to them. That being said, as of right now, only the pto model needs it so I am doing a belong_to and has_one association between the two

This commit is contained in:
Ken Johnson
2013-05-27 13:09:33 -04:00
parent 8bfdf45ff9
commit 21752fab7e
7 changed files with 79 additions and 1 deletions
@@ -0,0 +1,14 @@
class CreateSchedules < ActiveRecord::Migration
def change
create_table :schedules do |t|
t.string :event_type
t.date :date_begin
t.date :date_end
t.string :event_name
t.string :event_desc
t.integer :user_id
t.timestamps
end
end
end
+12 -1
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130525001150) do
ActiveRecord::Schema.define(:version => 20130527165832) do
create_table "paid_time_offs", :force => true do |t|
t.integer "user_id"
@@ -32,6 +32,17 @@ ActiveRecord::Schema.define(:version => 20130525001150) do
t.datetime "updated_at", :null => false
end
create_table "schedules", :force => true do |t|
t.string "event_type"
t.date "date_begin"
t.date "date_end"
t.string "event_name"
t.string "event_desc"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "email"
t.string "password"
+24
View File
@@ -104,6 +104,26 @@ paid_time_off = [
}
]
schedule = [
{
:user_id => 2,
},
{
:user_id => 3,
},
{
:user_id => 4,
},
{
:user_id => 5,
}
]
users.each do |user_info|
@@ -116,4 +136,8 @@ end
paid_time_off.each do |pto|
PaidTimeOff.create!(pto)
end
schedule.each do |event|
Schedule.create!(event)
end