Ruby on Rails 5.0 for Autodidacts: Learn Ruby 2.3 and Rails 5.0 by Stefan Wintermeyer

Ruby on Rails 5.0 for Autodidacts: Learn Ruby 2.3 and Rails 5.0 by Stefan Wintermeyer

Author:Stefan Wintermeyer [Wintermeyer, Stefan]
Language: eng
Format: azw3, mobi
Tags: Framework, MVC, Ruby, Ruby on Rails, Rails
Published: 2016-02-07T05:00:00+00:00


redirect_to :back

If you want to redirect the user of your web application to the page he has just been you can use redirect_to :back. This is very useful in a scenario where your user first has to login to get access to a specific page.

Flash Messages

In my eyes, the term “flash messages” is somewhat misleading. Almost anyone would associate the term “Flash” with more or less colorful web pages that were implemented with the Adobe Shockwave Flash Plug-in. But in Ruby on Rails, flash messages are something completely different. They are messages that are displayed, for example on the new page after a redirect (see section Redirects).

Flash messages are good friends with redirects. The two often work together in a team to give the user feedback on an action he just carried out. A typical example of a flash message is the system feedback when a user has logged in. Often the user is redirected back to the original page and gets the message “You are now logged in.”

As an example, we are once more constructing the ping pong scenario from section "Redirects":

$ rails new pingpong [...] $ cd pingpong $ rails generate controller Game ping pong [...]



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.