-
Notifications
You must be signed in to change notification settings - Fork 129
Feature/Create 'tutor_times' table and 'TutorTime' Model #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
ca5b893
36a44e7
10617e2
844065c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| class TutorTime < ApplicationRecord | ||
| belongs_to :user | ||
| belongs_to :task | ||
|
|
||
| validates :user_id, presence: true | ||
| validates :task_id, presence: true | ||
| validates :time_spent, presence: true, numericality: { greater_than_or_equal_to: 0.0 } | ||
|
|
||
| def time_spent_in_hours | ||
| (time_spent.to_f / 60.0).round(2) | ||
martindolores marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class CreateTutorTimes < ActiveRecord::Migration[7.1] | ||
| def change | ||
| create_table :tutor_times do |t| | ||
| t.references :user, null: false, foreign_key: { on_delete: :cascade } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the "user" here a tutor (staff) that is assigned within a unit? You could probably reference the staff from the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @b0ink :), I believe this would be a tutor, I can push up a change shortly. Im assuming I would also have to change the model then too right to include the following: class TutorTime < ApplicationRecord
...
belongs_to :unit_role
has_one :user, through: :unit_role
.... |
||
| t.references :task, null: false, foreign_key: { on_delete: :cascade } | ||
| t.decimal :time_spent, precision: 10, scale: 2, null: false, default: 0.0 | ||
| t.timestamps | ||
| end | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.