-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asscociate quotes and users to companies
- Loading branch information
1 parent
5fefbb3
commit bbaf368
Showing
7 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
class Company < ApplicationRecord | ||
has_many :users, dependent: :destroy | ||
has_many :quotes, dependent: :destroy | ||
|
||
validates :name, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
class User < ApplicationRecord | ||
devise :database_authenticatable, :validatable | ||
|
||
belongs_to :company | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCompanyReferenceToQuotes < ActiveRecord::Migration[7.1] | ||
def change | ||
add_reference :quotes, :company, null: false, foreign_key: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCompanyReferenceToUsers < ActiveRecord::Migration[7.1] | ||
def change | ||
add_reference :users, :company, null: false, foreign_key: true | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
first: | ||
company: kpmg | ||
name: First quote | ||
|
||
second: | ||
company: kpmg | ||
name: Second quote | ||
|
||
third: | ||
company: kpmg | ||
name: Third quote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
accountant: | ||
company: kpmg | ||
email: [email protected] | ||
encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %> | ||
|
||
manager: | ||
company: kpmg | ||
email: [email protected] | ||
encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %> | ||
|
||
eavesdropper: | ||
company: pwc | ||
email: [email protected] | ||
encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %> |