Archive for May, 2007

Markaby, Helpers and Select Tags

Thursday, May 31st, 2007

Markaby is great but it sometimes stumbles on helper methods. I’ve mentioned that you need to add a to_s onto urls. One other is it gets the ActionView::Helpers::FormOptionsHelper.select function and the Html select tag confused. Reading through the comments in various places there are various suggestions to resolve this – none of which worked for me.

So I did this in app/helpers/application_helper.rb

  # markaby doesn't like selects so give it something it does like  def drop_down object, method, choices, options = {}, html_options = {}    select object, method, choices, options, html_options  end

Now, in your view, instead of calling select you call drop_down :object, :method, choices and Markaby is happy. And the name drop_down? Well that’s what most of my users call them so it makes sense to me.

Great Features you see, Great Features you don’t

Friday, May 25th, 2007

I love the song “Standing Here” by the Stone Roses (you may notice a Roses-bent to this blog). Not only does it have some of John Squire’s finest noodlings, great lyrics and fantastic work by Mani – it also includes one of my favourite bits of backing vocals in the world. A simple “ooh ooh” from Reni. That’s not the clever bit though. In the first verse there is no “ooh ooh”. In the second verse there is one “ooh ooh”. In the third, there are two “ooh ooh”s. I can still remember the first time I noticed it (months after I first heard the song). I pointed it out to my friends and they were all impressed too.

Just a tiny detail.

Hard to spot.

But once you’ve seen it you notice those same, tiny, details in their other songs. That craftsmanship, that attention to detail, is what made them great songwriters (at least till the Second Coming when Squire shoved Geffen’s money up his nose).

In the same vein, I have just spent twenty minutes adding a similar detail to our application. One that most people will never ever notice. But if they do, they will think “that’s nice” and for thirty seconds they will feel good about their choice to shell out cash on us. And the feature? It’s this:

Spotted it yet? How about here?

That’s right – the person object has a gender field and, based upon the gender, it displays the correct possessive – his or her (or their if not known) in the menus. Again, a tiny detail. But they all count.

RJS Templates

Tuesday, May 22nd, 2007

I love RJS. It means I don’t have to wade through Javascript (yeuch). But RJS templates have been bothering me for a while. You see your .rhtml and your .mab files literally are views. They define HTML as it appears on-screen. But your .rjs files are not. They manipulate what is there but they do not define it. The proof of this is when you find yourself writing:

page.replace_html 'something', :partial => 'something', :object => @something

The RJS defines what you want to happen to the page but what actually gets displayed is in _something.mab (or _something.rhtml).

So I have decided to do the following from now on: no more .rjs “views” – instead I will code my controllers like this:

def new  @something = Something.new  respond_to do | format |    format.js { render_new_as_js }  endend

private

def render_new_as_js  render :update do | page |    page.replace_html 'something', :partial => 'something', :object => @something    page.visual_effect :highlight, 'something'  endend 

In other words code stays in the controller and html stays in the views.

Totally Off Topic but I’m incensed

Sunday, May 6th, 2007

This is the stupidest thing I have ever heard. Children aren’t robots – they need breaks. They need to work off their energy. They need physical activity. What’s the betting that they have massive numbers of exclusions for the boys at this so-called school. Fucking idiots. Unbelievable.

One of the best designs I’ve ever seen

Thursday, May 3rd, 2007

While the recent Google Homepage outage has made me think long and hard about how I manage my online data, I have to say that this site has one of the best designs I’ve ever seen.