This small feature may help clean up some code. You can register your own flash types to use in
redirect_to calls and in templates. For example:# app/controllers/application_controller.rbclass ApplicationController add_flash_types :error, :catastropheend# app/controllers/things_controller.rbclass ThingsController < ApplicationController def create # ... create a thing rescue Error => e redirect_to some_path, :error => e.message rescue Catastrophe => e redirect_to another_path, :catastrophe => e.message endend# app/views/layouts/application.html.erb<div class="error"><%= error %></div><div class="catastrophe"><%= catastrophe %></div>
No comments:
Post a Comment