def errors_on(object, attribute)
      error_message = object.errors[attribute].first
      content_tag(:span, error_message, class: "blogit_error_message") if error_message
    end
def errors_on(object, attribute)
      error_message = object.errors[attribute].first
      content_tag(:span, error_message, class: "blogit_error_message") if error_message
    end
The first error message for an ActiveRecord::Base model instance attribute

 object    - An ActiveRecord::Base instance to check
 attribute - A Symbol or String with the attribute name to check errors on

 Examples

  errors_on(@user, :first_name)
  # => "Can't be blank"

 Returns a String with the error message