To Examples
OnlineQuiz Directions
Create a new rails project named OnlineQuiz.
Navigate to the OnlineQuiz folder.
Generate a model named Answer with these fields:
Field
Datatype
name
string
ans1
string
ans2
string
ans3
string
ans4
string
ans5
string
Enter this rake statement to create the database:
rake db:migrate
Generate a controller with name Quizwith views questions and answers.
Use this code for the controller
quiz_controller.rb
.
Use this code for the views
questions.html.erb
and
answers.html.erb
.
Add this route to the config/routes.rb file:
post "/quiz/answers"
Add a layout page and a CSS style file.
View the questions view in a browser at this URL:
http://localhost:3000/quiz/questions