Create Action Lab
Build a working
createactionUse a
form_tagto create a new form that submits to theindexactionCorrectly name form fields so that they end up at the top level of the
paramshashAssign data from
paramsto aStudentobject in thecreateactionSave that
Studentobject in thecreateactionCreate a
redirect_tofrom thecreateaction to theshowaction
Instructions
Many of the spec tests are already passing for this lab, but there are some additional ones –– including our first use of controller tests –– located here:
Controller Specs -
specs/controllers/students_controller_spec.rbCapybara Specs -
specs/features/student_spec.rb:37
When this lab is complete, your application should have the following behavior:
User fills out the form on
students/newWhen the form is submitted, a new record is created in the database
After the user submits the form, they are redirected to the
showpage that renders theStudentrecord that they created
Make sure to use a route helper method to redirect to the show page at the end of the create method. You can find the correct syntax for this route by running rake routes in the terminal.
Resources
Clone https://github.com/learn-co-curriculum/rails-create-action-lab
Last updated