quirkey / flashdance
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Mon Feb 18 14:11:08 -0800 2008 | |
| |
README.rdoc | Sun Dec 21 20:59:38 -0800 2008 | |
| |
Rakefile | Sat Feb 09 21:52:37 -0800 2008 | |
| |
example/ | Mon Feb 18 14:11:08 -0800 2008 | |
| |
init.rb | Mon Oct 12 14:58:25 -0700 2009 | |
| |
install.rb | Sun Dec 21 20:56:27 -0800 2008 | |
| |
lib/ | Mon Oct 12 14:58:25 -0700 2009 | |
| |
tasks/ | Sat Feb 09 21:52:37 -0800 2008 | |
| |
test/ | Mon Feb 18 14:11:08 -0800 2008 |
Flashdance
Flashdance is a drop in replacement for flash in action controller. It stores all your assorted messages in a single YAML file.
The default location for the YAML file is: app/views/shared/flash.yml
You can change this with:
Quirkey::Flashdance::Loader.yml_path = File.join(RAILS_ROOT,'app','views','your_folder','your_flash.yml')
You can email me at aaron at quirkey for bug reports/comments/suggestions
Example
Flashdance bends a lot of different ways:
At its most unobtrusive:
# in your controller
def update
# . . . booring part where record gets updated
flash[:warning] = flashdance(:this_failed) #=> This failed
end
A little nicer:
def update
# . . .
flash(:message => 'all_is_good') # YAML entries can be referred to by strings or symbols
# equivalent to flash[:message] = "This is great"
end
ERB is evaluated in the context of the controller so you can do fun things like:
def tell_off_the_spammer
# . . .
@email = 'jon@example.com'
flash(:warning => :using_erb)
# equivalent to flash[:warning] = "you are an idiot, jon@example.com"
end
So what if your app is huge and you use these flash thingies all over the place? Your YAML file might get big and unreadable. Well, thats why you can nest! Nested sections are refered to by arrays.
def make_a_nest
# . . .
flash(:nest => [:section,:subsection])
# equivalent to flash[:nest] = "I'm nested"
end
Flashdance automatically checks for entries nested in the controller/action path where you call it from. And heres where you get splashed with that big bucket of water:
class MyController < ApplicationController
# . . .
def my_action
# . . . where you dance your heart out
flash(:message)
# equivalent to flash[:message] = "I'm soaking wet"
end
end
Read more: www.quirkey.com/blog/
Installation
Latest is the Git on the Hub: github.com/quirkey/flashdance
From Github (legacy):
./script/plugin install git://github.com/quirkey/flashdance.git
Copyright © 2008 Aaron Quint / Quirkey NYC, LLC. , released under the MIT license
