Skip to content

Instantly share code, notes, and snippets.

@szabcsee
Last active August 29, 2015 13:56
Show Gist options
  • Save szabcsee/9088668 to your computer and use it in GitHub Desktop.
Save szabcsee/9088668 to your computer and use it in GitHub Desktop.
Rack-Flash3 proper implementation on Sinatra
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>This is the sandbox playground of Sinatra</title>
</head>
<body>
<% [:notice, :warning, :error].each do |key| %>
<% if flash.include?(key) %>
<h2 class="alert <%= key %>"><%= flash[key] %></h2>
<% end %>
<% end %>
<%= yield %>
</body>
</html>
require 'sinatra'
require 'rack-flash'
enable :sessions
use Rack::Flash
get '/flash/:flash' do
flash[:notice] = params[:flash]
erb :flash
end
get '/flash-redirect' do
flash[:error] = 'Ez már a redirect előtti üzenet.'
redirect to('/flash-redirected')
end
get '/flash-redirected' do
erb :flash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment