Controllers can redirect requests to a different action. This can happen at any point in the handling of the requests. A redirect is actual a brief response to the web browser asking the browser to issue a new request to a different URL. That URL can be local or remote. Even though the redirect takes place very quickly, it is is important to realize that it is actually a new request to the Rails application.
- [Instructor] In this movie, we'll learn how to…redirect actions from the controller.…Controllers can respond to requests by rendering a view…back to the browser.…But the diagram that we've been looking at is deceptive…because it appears that the controller's final step…must be to render a view.…But it can also make a different choice,…and that is to perform a redirect instead.…Redirects send a request to a different…controller and action.…Imagine this scenario; a user requests a page…which is inside a password protected area,…so the first thing the controller's gotta do…is check to see if the user is logged in or not.…
If the user is logged in, then it will let them have…the page that they wanted, but if not,…then the controller wants them to log in first,…and so it redirects them to a login page instead.…We could use render to render that login page,…but that would just be rendering the login template.…What we really want is to send the user…to the new URL for the login page…and run any controller action code that's associated with it…
- 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.