From d15c910aa92fd0c38c8430d34003c0ddc97a0c1c Mon Sep 17 00:00:00 2001 From: Nikita Kholin Date: Sat, 29 Jul 2017 19:07:08 +0300 Subject: [PATCH] Add schema information to models --- app/models/activity.rb | 11 +++++++++++ app/models/room.rb | 10 ++++++++++ app/models/room_activity.rb | 12 ++++++++++++ app/models/room_request.rb | 11 +++++++++++ app/models/user.rb | 16 ++++++++++++++++ 5 files changed, 60 insertions(+) diff --git a/app/models/activity.rb b/app/models/activity.rb index fa1162a..f7dc526 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,4 +1,15 @@ # Activity is a record of completed RoomActivity by someone +# +# == Schema Information +# +# Table name: activities +# +# id :integer not null, primary key +# created_at :datetime +# updated_at :datetime +# user_id :integer +# room_activity_id :integer +# class Activity < ApplicationRecord belongs_to :user belongs_to :room_activity diff --git a/app/models/room.rb b/app/models/room.rb index 2a5e838..a6ae143 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,5 +1,15 @@ # A room is a place where users who live in that room do activities like # 'taking out trash' with their roommates +# +# == Schema Information +# +# Table name: rooms +# +# id :integer not null, primary key +# created_at :datetime +# updated_at :datetime +# name :integer not null +# class Room < ApplicationRecord has_many :users has_many :room_activities, dependent: :destroy diff --git a/app/models/room_activity.rb b/app/models/room_activity.rb index 8681cce..7263743 100644 --- a/app/models/room_activity.rb +++ b/app/models/room_activity.rb @@ -1,4 +1,16 @@ # Room activities are activities that room uses +# +# == Schema Information +# +# Table name: room_activities +# +# id :integer not null, primary key +# created_at :datetime +# updated_at :datetime +# name character :string +# room_id :integer +# enabled :boolean DEFAULT(true) +# class RoomActivity < ApplicationRecord DEFAULT_ROOM_ACTIVITIES = [ 'taking out trash', diff --git a/app/models/room_request.rb b/app/models/room_request.rb index 0048b9d..31390f2 100644 --- a/app/models/room_request.rb +++ b/app/models/room_request.rb @@ -1,4 +1,15 @@ # Room requests are requests for joining the room +# +# == Schema Information +# +# Table name: room_requests +# +# id :integer not null, primary key +# created_at :datetime +# updated_at :datetime +# room_id :integer +# sender_id :integer +# class RoomRequest < ApplicationRecord belongs_to :room belongs_to :sender, class_name: 'User' diff --git a/app/models/user.rb b/app/models/user.rb index f7d88ef..19929f3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,20 @@ # User is a preson, who lives in a hostel room +# +# == Schema Information +# +# Table name: room_requests +# +# id :integer not null, primary key +# created_at :datetime +# updated_at :datetime +# name :string DEFAULT(''), not null +# email :string DEFAULT(''), not null +# encrypted_password :string DEFAULT(''), not null +# room_id :integer +# provider :string +# uid :string +# photo_url :string +# class User < ApplicationRecord belongs_to :room, optional: true has_many :activities