O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Flash Responder

The scaffolded controller uses flash messages in both create and update actions. These messages are quite similar across different controllers. Wouldn’t it be nice if we could set these flash messages by default inside responders but still provide a nice API to change them?

Let’s implement this feature using the internationalization framework (I18n) so we can easily look up flash messages from YAML files, configure default values, and make it possible to translate such messages in the future. Let’s use rails plugin to create a new project called responders:

 
$ ​rails plugin new responders

Let’s start by writing some tests that access create, update, and destroy actions and ensure a flash message is being exhibited to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required