Write the Ruby code in the controller actions to process the data sent by the login form and to log out the user.
- [Instructor] In the last movie we created…the routes, controller, and view templates…we need for user authentication.…In this movie we'll add the controller actions…to handle logging in and logging out.…So let's start with coding the attempt_login.…So attempt_login is what happens…when the login form is submitted…and we should have two parameter values that we receive,…one for username and one for password.…Let's start by just checking to make sure…that those are sent to us.…If params[:username].present?,…present is a rails method that is the opposite of blank.…
So it's exactly like blank, but it's the opposite.…So it's not blank, so username is not blank,…and params[:password] is present,…or not blank,…then we're going to try to find the user in the database.…If we haven't gotten them then we're…not even going bother trying to go the database.…No reason to look it up.…We know it will fail.…So next we want to try and find the user in the database,…and then we'll check to see if the password matches.…So let's do found_user equals,…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.