To Examples
Hospital2 Example
Directions
Create a new Rails project named
Hospital2.
Generate a Rails model named
Doctor
with these fields.
Field
Datatype
name
string
office_num
integer
phone_num
string
Generate a Rails model named
Patient
with these fields.
Field
Datatype
last_name
string
first_name
string
gender
string
phone_num
string
doctor_id
integer
Source code for the seed file
Hospital2/db/seeds.rb
.
Add the line
has_many :patients
to the
Doctor
model.
Add the line
belongs_to :doctor
to the
Patient
model.
Generate a controller named ContactInfo with view show:
contact_info.rb
show.html.erb
contact_info.scss
View the show page with this URL:
http://localhost:3000/contact_info/show