Skip to content

Commit

Permalink
a flash implementation where flash_reset need not to be integrated in…
Browse files Browse the repository at this point in the history
… the layout

Signed-off-by: Balint Erdi <balint.erdi@gmail.com>
  • Loading branch information
balinterdi committed Feb 26, 2009
1 parent 285dea1 commit 9308679
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions my_helpers.rb
Expand Up @@ -12,10 +12,10 @@ def self.included(base)
module Flash

def flash
if !session.key?("flash")
session["flash"] = Hash.new
if !@flash
@flash = (session["flash"] = Hash.new)
end
session["flash"]
@flash
end

def reset_flash
Expand Down
4 changes: 4 additions & 0 deletions the_pot.rb
Expand Up @@ -54,6 +54,10 @@ def current_user

end

before do
@flash = reset_flash
end

get '/main.css' do
content_type 'text/css', :charset => 'utf-8'
sass :main
Expand Down
3 changes: 1 addition & 2 deletions views/layout.haml
Expand Up @@ -13,8 +13,7 @@
- if flash[:ok]
.ok= flash[:ok]
- if flash[:error]
.ok= flash[:error]
.error= flash[:error]
#container
= yield
- reset_flash

0 comments on commit 9308679

Please sign in to comment.