From the course: Ruby on Rails 6: Controllers and Views

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Controllers

Solution: Controllers - Ruby on Rails Tutorial

From the course: Ruby on Rails 6: Controllers and Views

Start my 1-month free trial

Solution: Controllers

(upbeat music) - [Instructor] Hopefully you were able to use what you've learned about the features inside Rails controllers to complete the challenge assignment. If not, or if you just want to check your work against mine, I'll show you the solution that I came up. The first task was to record a note in the log file every time a user logs out. So that's going to be in the access_controller and right down here in the destroy action, you see I've got logger.info. And I'm logging out the user and I'm going ahead and just putting in whatever their session ID was so that I have some kind of identifier to let me know who logged out. I also modified the login action to work the same way. So now we'll have a record in our log file when a user logs in or when they log out. The second task was to set username automatically for every controller in the app. You may remember that we already had set_username as a method and we…

Contents