- Build a working create action
- Use form_tag to create a new form that submits to action
- Correctly name form fields so that they end up in params on the top level
- Assign data from params to an instance in create
- Save an instance in a controller action
- Redirect_to from a controller action to a show page
- Use a named route for the new page and put it on the index page
There are a some additional RSpec specs for this lesson, including our first use of controller tests. You can find the three new tests that have to pass here:
-
Controller Specs -
specs/controllers/students_controller_spec.rb
-
Capybara Specs -
specs/features/student_spec.rb:37
For the use case scenario, after this lab is completed your application should have the following behavior:
-
User fills out the form on
students/new
-
When the form is submitted a new record is created in the database
-
After the user fills out the form they are redirected to the
show
page that renders thestudent
record that they created
Make sure to use a route helper method to redirect to the student
show
page at the end of the create
method, you can get this route by running rake routes
in the terminal
View Create Action Lab on Learn.co and start learning to code for free.