Hidden gem – error_message_on
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:

8 comments.
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?
You mean you don’t have a Flickr account? Preposterous!
http://farm1.static.flickr.com/246/528775607_249000c1cf_o.png
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.
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.
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.
Thanks for bringing it up to my attention. I will definitely make that I use publicly available links in the future.
Leave a Reply