WARNING : This table can be named as "JoinTableMasseurCompany" in other issues. If you find it this way, replace the name by "Reservation".
Why ?
A company will be able to interact with a masseur, asking him one or several reservations among the multiple proposed slots.
How
Create the model
[ ] run the command rails g model Reservation ..........
Migration editing :
go to the migration file generated by this command
[ ] add the following line code : t.belongs_to :masseur_profile, index: true.
[ ] add the following line code : t.belongs_to :company_profile, index: true.
Model editing :
Go to the model file _masseurprofile.rb and write the following code :
[ ] belongs_to :masseur_profile
[ ] belongs_to :company_profile
[ ] validates :......., presence: true
[ ] validates :masseur_profile, presence: true
[ ] validates :company_profile, presence: true
Testing the model in console (we need the other following models to be created before these tests : Company, CompanyProfile, Masseur, MasseurProfile).
Testing link to CompanyProfile and MasseurProfile models :
[ ] run rails console --sandbox and create a masseur : Masseur.create(email: "test@example.com", password: "123456", password_confirmation: "123456").
Then create a MasseurProfile : take the ID of the last created masseur Masseur.last, and next, MasseurProfile.create(masseur_id: the_id_of_the_last_created, first_name: "toto", last_name: "test", description: "Text written to fill the description attribute text text text", authorized: true)
[ ] create a company : Company.create(email: "test2@example.com", password: "123456", password_confirmation: "123456").
Then create aCompanyProfile : take the ID of the last created company Company.last
Next, CompanyProfile.create(company_id: the_id_of_the_last_created, name: "test", authorized: true).
[ ] Now CompanyProfile and MasseurProfile are properly created, create a Reservation to make the Company ask the Masseur for a slot : Reservation.create(........, masseur_profile: MasseurProfile.last, company_profile: CompanyProfile.last)
Must Have
A working reservation model able to save the two correspondents, a specific slot and set a value to accepted or denied.
WARNING : This table can be named as "JoinTableMasseurCompany" in other issues. If you find it this way, replace the name by "Reservation".
Why ? A company will be able to interact with a masseur, asking him one or several reservations among the multiple proposed slots.
How Create the model
rails g model Reservation ..........
Migration editing :
t.belongs_to :masseur_profile, index: true
.t.belongs_to :company_profile, index: true
.Model editing :
belongs_to :masseur_profile
belongs_to :company_profile
validates :......., presence: true
validates :masseur_profile, presence: true
validates :company_profile, presence: true
Testing the model in console (we need the other following models to be created before these tests : Company, CompanyProfile, Masseur, MasseurProfile). Testing link to CompanyProfile and MasseurProfile models :
rails console --sandbox
and create a masseur :Masseur.create(email: "test@example.com", password: "123456", password_confirmation: "123456")
. Then create a MasseurProfile : take the ID of the last created masseurMasseur.last
, and next,MasseurProfile.create(masseur_id: the_id_of_the_last_created, first_name: "toto", last_name: "test", description: "Text written to fill the description attribute text text text", authorized: true)
Company.create(email: "test2@example.com", password: "123456", password_confirmation: "123456")
. Then create aCompanyProfile : take the ID of the last created companyCompany.last
Next,CompanyProfile.create(company_id: the_id_of_the_last_created, name: "test", authorized: true)
.Reservation.create(........, masseur_profile: MasseurProfile.last, company_profile: CompanyProfile.last)
Must Have A working reservation model able to save the two correspondents, a specific slot and set a value to accepted or denied.
Reading List