Last active
August 29, 2015 13:56
-
-
Save szabcsee/9088668 to your computer and use it in GitHub Desktop.
Rack-Flash3 proper implementation on Sinatra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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