Archive for the ‘Markaby’ Category

Thursday, October 25th, 2007

You know how it is - there are some things that you are just not comfortable without. My phone in my back pocket, my wallet in my front pocket, the key in the front door when I go to bed (just in case there’s a fire and we have to make a hasty exit), the dog under my feet (tripping me up), one of my large collection of jackets (current favourite: leather biker jacket).

And so it is with Rails projects. Before I do anything I do the following:

  • Load the Exception Notification plug-in and configure it with my email address
  • Load the form_test_helper plug-in so I can confidently test my forms
  • Load the ARTS plug-in so I can confidently test my AJAX user interfaces
  • Load Markaby so my views are beautifully coded and semantically correct
  • Create the Rails session store within the database (rake db:sessions:create)

Of these, the one I really can’t do without is Markaby (although ARTS comes a close second). I don’t know what it is (apart from Why the Lucky Stiff is genius). I can’t stand looking at rhtml files any more - too many angle brackets for a start. Instead, my mabs are things of beauty - and as I write the code to produce the views, I find that they are more semantically correct as well. For example:

div.row do  label “Email Address: “  text_field :person, :email_address  p.explanation “Please supply a valid email address so that we can send you a confirmation email”end

As I’m writing the Markaby code, class names like “explanation” seem to fit naturally - the code reads better, the HTML is semantic and the CSS is simple.

What more could you want?

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.

Monday, April 23rd, 2007

One thing to watch out for, when using Markaby:

  link_to_remote ‘whatever’, :url => some_path(@something), :before => do_this, :complete => do_that

will not work.

Instead you need:

  link_to_remote ‘whatever’, :url => some_path(@something).to_s, :before => do_this, :complete => do_that

Spot the difference? The :url parameter has a .to_s appended on the end. Otherwise Markaby intercepts the call and eats the output.