Flashdance plugin

Plugin details

Flashdance is a drop in replacement for flash in action controller. It stores all your assorted messages in a single YAML file.

Websitehttp://www.quirkey.com/blog/2008/02/29/drying-up-rails-flash-with-flashdance/ Repositorysvn://svn.quirkey.com/quirkey_tools/trunk/flashdance/ Author Aaron Quint Tags flash LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://svn.quirkey.com/quirkey_tools/trunk/flashdance/

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')



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

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, about 1 month ago