Mr eel

Error Display Helpers

The existing error helpers in Rails are pretty nice, but lack one major feature I was looking for. I wanted to have errors displayed for more than one model at a time. For example adding a schedule to a job when it is created in a CRM system.

So I knocked something together myself:

def error_messages(*keys)
	errors = []
	# Check the errors for each object specified
	keys.each do |key|
		object = instance_variable_get("@#{key}")
		unless object.errors.empty?
			object.errors.full_messages.collect { |msg| errors < < content_tag("li", msg) }
		end
	end
	if errors.length > 0
		content_tag("div",
			content_tag("h2", "#{pluralize(errors.length, "error")} prohibited this form from being saved.") +
			content_tag("p", "These are the problems with this form:") +
			content_tag("ul", errors.each { |li| li }),
			:id => 'errorMessage'
		)
	end
end

A couple of things to note about this helper. It’s based fairly closely on the existing helpers in Rails, but doesn’t allow you to customise the class names or ids used for the HTML elements, nor does it let you choose the heading. I’ll expand this in the future to make it more re-usable.

You can call it in your templates like so; < %= error_messages(:job, :schedule) %>. You can see I’m asking for the helper to display errors for the objects stored in the instance variables @job and @schedule.

One interesting thing I noticed is the method instance_variable_get(). It takes a key and returns a reference to an instance variable… obviously. Nice! Now I understand why Rails makes such heavy use of keys. The memory requirements are smaller and they can easily be used to reference instance variables if needed.

Posted on September 27th, 2005 | There are 3 comments

The 10th Circle of Hell: Dependency Hell

Ahh, I’ve just spent the afternoon trying to get Ruby playing along with Subversion. I’m looking to use Collaboa to track my development.

Unfortunately it involves installing a number of other dependencies to get it all working. Even with FreeBSD’s fine ports system, it’s become confusing. And frustrating. And ultimately enraging.

If I figure it out, I’m going to write a step by step install guide. Who knows? I may actually be able to save some other poor souls from getting burned by the flames of Dependency Hell.

Posted on September 21st, 2005 | There are 0 comments

An Analysis of the Revolution Controller from a Business Perspective

I do so love long titles. I can pretend I’m writing a long treatise on frog organs or something.

Anyhow, to the subject at hand; Lost Garden has a great analysis of the new Revolution controller. It makes for some really interesting reading.

I get to stroke my chin and exclaim things like “well tickle my wizz-nibbles, he’s right!” and “by Jove!” and “far… beyond… metal!”

Posted on September 19th, 2005 | There are 0 comments

The Nintendo Revolution Controller Inspires Awe, Disbelief and Derision

For many Nintendo fan-boys, the big day has come. Nintendo have finally revealed the Revolution controller. IGN Cube have had a hands-on demo.

It looks really interesting. Dramatically different to anything else on the market. In case anyone was in doubt, Nintendo weren’t kidding when they said they wanted to do something totally different. It shows the Xbox 360 and PS3 for what they are. Same shit, new packaging.

As always, IGN’s editorialisation is half-arsed.

“However, the exciting part is that most games that are actually made for Revolution will be very unique and that’s what Nintendo is aiming for. Unfortunately, as the DS has proven, unique doesn’t always equal better gameplay.”

The first part of this statement is correct. There are plenty of unique and crappy games. However, I disagree with the second half. Granted quality is subjective, but I think it’s incorrect to imply that the DS has failed to produce any great games.

Let me count the games (ways)! Pac-Pix, Kirby’s Cursed Canvas, Wario Ware, Nintendogs, Meteos etc. Some really interesting and fun games.

They then go on to question how well it will work with existing games! Talk about totally missing the point. Firstly, Nintendo are interested in seeing new and interesting styles of gameplay, hence the controller design. Secondly, I’m sure they have already considered backwards compatibility, after all they are hoping to offer their back-catalogue for download.

Not to pick on IGN too heavily, but I think their response to the controller is indicative of the industry as a whole; conservative and close-minded. Journalism like this is doing the industry harm. It makes the punters skeptical and publishers risk-averse.

Regardless, I do think that Nintendo will succeed with the Revolution. The success of the DS vindicates their philosophy.

EDIT: OK, maybe I’m being a bit too harsh on IGN. In the end they are quite positive about the possibilities that the controller offers. Still, I think the point is a valid one. The industry is getting stale and conservative, and the journalists ain’t by and large aren’t helping.

Posted on September 16th, 2005 | There are 0 comments

Just stop it!

Please stop trying to cover Prince songs. They’ll never be as good as the original.

Posted on September 8th, 2005 | There are 0 comments

Web Design eh?

Take these small nuggets of wisdom from a premature curmudgeon:

A big widget made using Flash is not a website.

A website with it’s own soundtrack means the developers hate you and really really want to annoy you.

Putting your site in a pop-up means it must be some horrible ad or something. Let’s ignore it.

Having Javascript resize the browser window is sorta like having a radio station turn the volume right up. It’s annoying. Stop it.

Learning stuff is great! Those slow moving graphic design companies who mistakenly think of web design merely as an extension of print design um… should stop doing that. Instead they should learn about the technologies and the possibilities they offer.

Burnt fig jam totally rules.

Posted on September 1st, 2005 | There are 0 comments

All contents © 2005—2007 Luke Matthew Sutton