To get a complete set of informations about the Company.
How ?
Create the model
[x] run $ rails g model CompanyProfile name:string
Migration editing :
go to the migration file generated by this command
[x] add t.belongs_to :company, index: true
Model editing :
Go to the model file company_profile.rb and write the following code :
[x] validates :name, presence: true
[x] belongs_to :company
Testing the model in console (we need the other following models to be created before these tests : Company, Masseur, MasseurProfile, Employee, EmployeeProfile).
Testing link to Company devise model :
run rails console --sandbox and create a company : Company.create(email: "test@example.com", password: "123456", password_confirmation: "123456"). Then test the CompanyProfile creation : take the ID of the last created company Company.last, and next, CompanyProfile.create(company_id: the_id_of_the_last_created, name: "test", authorized: true)
[x] test CompanyProfile.create in the console locally
[x] create 5 Company Profiles in the seed
Controller
[x] CRUD
Views
[x] Edit profiles views
Must Have
[x] A complete CompanyProfile model, connected to the Company model made with devise.
Why ?
To get a complete set of informations about the Company.
How ?
Create the model
[x] run
$ rails g model CompanyProfile name:string
Migration editing :
go to the migration file generated by this command
[x] add
t.belongs_to :company, index: true
Model editing :
Go to the model file company_profile.rb and write the following code :
[x] validates :name, presence: true
[x] belongs_to :company
Testing the model in console (we need the other following models to be created before these tests : Company, Masseur, MasseurProfile, Employee, EmployeeProfile). Testing link to Company devise model :
run rails console --sandbox and create a company : Company.create(email: "test@example.com", password: "123456", password_confirmation: "123456"). Then test the CompanyProfile creation : take the ID of the last created company Company.last, and next, CompanyProfile.create(company_id: the_id_of_the_last_created, name: "test", authorized: true)
CompanyProfile.create
in the console locallyController
Views
Must Have
Reading List
generating a model : https://guides.rubyonrails.org/getting_started.html#creating-the-article-model
attributes validations in model : https://guides.rubyonrails.org/active_record_validations.html
seed : https://www.thehackingproject.org/dashboard/courses/1/weeks/4/days/3?locale=fr
seed : https://edgeguides.rubyonrails.org/active_record_migrations.html#migrations-and-seed-data
https://www.thehackingproject.org/dashboard/courses/1/weeks/5/days/2?locale=fr
https://www.thehackingproject.org/dashboard/courses/1/weeks/5/days/3?locale=fr
https://guides.rubyonrails.org/action_controller_overview.html
https://guides.rubyonrails.org/routing.html