Displaying Flash’s in Rails easily

Rails can handle multiple Flash states in the flash hash, e.g. :notice, :error, :success. But how do you display these messages in a no nonsense fashion?

In all my Rails applications I make use of the Flash method for displaying simple messages about system changes to the user, such as “Welcome back Ivan” when they login, or “Your details have been saved successfully” when the user saves their profile.

Rails can handle multiple Flash states in the flash hash, e.g. :notice, :error, :success. But how do you display these messages in a no nonsense fashion? with this simple display_flashes helper method I’ve written.

1
2
3
4
5
6
7
8
9
10
11
12
module ApplicationHelper
 
  def display_flashes
    return if flash.blank?
    flash_type = flash.keys.first.to_sym
 
    return content_tag(:div, :id => "flash_box", :class => "flash-wrapper") do
      content_tag(:div, flash[flash_type], :class => "flash #{flash_type}")
    end
  end
 
end

(more…)

The survey for people who make websites

Do you mind if we ask you a few questions?

A List Apart, the people who bought you Hybrid CSS Dropdowns would like to ask you a few questions, so go ahead, take the survey for people who make websites.

New design

New domain. New Design.

I’ve been working on this in my spare time for a few weeks now, as you can see, there is lots of room for improvement, more updates soon.

IE PNG Transparency fix

Making IE behave more like a browser

Odin over at Twe4ked Studios has done a good write up on a fix for the Internet Explorer PNG transparency issue, using custom CSS behaviour hacks. Check it out

Google Streetview got there before me

Google is driving down under.

The gateway to Mullumbimby, the biggest little town in Australia, also my hometown, located shortly west of Byron Bay. Quite possibly one of few places Google didn’t beat me to.

View Larger Map

Wappmosphere gets mobile

Blogging from the iPhone

I have just installed wordpress on our new server in canberra and the first thing I was dying to do was write a post from my iphone. So here it is. (more…)

Return of the Beer.new

Beer.drinkable

Yes that’s right, last month when I was visiting the Sydney Ruby on Rails monthly meetup I was introduced to the Beer model, not the type of model your thinking about, something more along the lines of:

class Beer < ActiveRecord::Base
  CAT_PISS = 2
  named_scope :drinkable, :conditions => ['quality > ?', CAT_PISS]
  # ...
end
 
Beer.drinkable
 
#=> [#<Beer id: 25, name: "Tooheys New", quality: 4, rating: 7.1, best_served: "cold">, 
#<Beer id: 17, name: "Corona", quality: 7, rating: 9.0, best_served: "cold with lime" >]

(Its a Rails thing)