SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.

Hidden gem – error_message_on

Posted on June 3rd, 2007 by Alex Gorbatchev. In Rails. 8 comments!

Story goes like this: I was trying to find a way to display form error messages in a pretty tight place. Using your regular error_messages_for creates a pretty long list and makes my page scroll.

Turns out, ActiveRecordHelper has another far much less known method called error_message_on. I thought it was just me at first, but a quick look on Google revealed that error_message_on returns only 3,240 hits where as error_messages_for comes in at 16,200 hits.

Here’s how this looks like in code:

<label for="email">Email <%= error_message_on :user, :email %></label>
<%= f.text_field(:email) %>

And with a little bit of CSS magic this is what the form looks like:

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

8 comments.

  1. Hey I tried to look at your screenshot but that yahoo site makes me log in, so I can’t see it. Any chance of putting screenshots somewhere else that doesn’t require a login just to look at them?

  2. Alex Gorbatchev

    You mean you don’t have a Flickr account? Preposterous! :)

    http://farm1.static.flickr.com/246/528775607_249000c1cf_o.png

  3. Brian

    I also don’t have a Flickr account and I won’t sign up to see an image…sorry if you don’t understand that. Thanks for the link so I could see it.

  4. Alex Gorbatchev

    It’s a joke, don’t take it so seriously :)

    I actually had no idea you need to login to Flickr to see images. I guess it’s because I’m just permanently logged in ever since I signed up a couple of years ago. I only decided to pay for it just recently though because Picasa web just sucks and Zoomr is a quite slow for me and too unstable.

  5. Brian

    I figured it was a joke, I just wanted to make sure you knew that it might be an issue for more readers that are not speaking up. I think that Yahoo did a big disservice to the Flickr community by forcing this.

  6. Alex Gorbatchev

    Thanks for bringing it up to my attention. I will definitely make that I use publicly available links in the future.

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> , rel="nofollow" in use - no link dropping, no keywords or domains as names; do not spam, and do not advertise!

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr