Skip to content

Commit

Permalink
Create RoomActivity model
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 19, 2017
1 parent d96da49 commit cfd214a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# 'taking out trash' with their roommates
class Room < ApplicationRecord
has_many :users
has_many :room_activities, dependent: :destroy
has_many :room_actions, dependent: :destroy
has_many :actions, through: :room_actions
has_many :room_requests, dependent: :destroy
Expand Down
4 changes: 4 additions & 0 deletions app/models/room_activity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Room activities are activities that room uses
class RoomActivity < ApplicationRecord
belongs_to :room
end
10 changes: 10 additions & 0 deletions db/migrate/20170719174950_create_room_activities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateRoomActivities < ActiveRecord::Migration[5.0]
def change
create_table :room_activities do |t|
t.string :name
t.belongs_to :room, foreign_key: true

t.timestamps
end
end
end
23 changes: 22 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170310222020) do
ActiveRecord::Schema.define(version: 20170719174950) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -38,13 +38,31 @@
t.index ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type", using: :btree
end

create_table "invites", force: :cascade do |t|
t.integer "user_id"
t.integer "room_id"
t.string "token"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["room_id"], name: "index_invites_on_room_id", using: :btree
t.index ["user_id"], name: "index_invites_on_user_id", using: :btree
end

create_table "room_actions", force: :cascade do |t|
t.integer "room_id"
t.integer "action_id"
t.index ["action_id"], name: "index_room_actions_on_action_id", using: :btree
t.index ["room_id"], name: "index_room_actions_on_room_id", using: :btree
end

create_table "room_activities", force: :cascade do |t|
t.string "name"
t.integer "room_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["room_id"], name: "index_room_activities_on_room_id", using: :btree
end

create_table "room_requests", force: :cascade do |t|
t.integer "room_id"
t.integer "sender_id"
Expand Down Expand Up @@ -92,8 +110,11 @@
t.index ["room_id"], name: "index_users_on_room_id", using: :btree
end

add_foreign_key "invites", "rooms"
add_foreign_key "invites", "users"
add_foreign_key "room_actions", "actions"
add_foreign_key "room_actions", "rooms"
add_foreign_key "room_activities", "rooms"
add_foreign_key "room_requests", "rooms"
add_foreign_key "user_actions", "room_actions"
add_foreign_key "user_actions", "users"
Expand Down
6 changes: 6 additions & 0 deletions spec/factories/room_activities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :room_activity do
name 'MyString'
room nil
end
end

0 comments on commit cfd214a

Please sign in to comment.