Rails: Printing validation errors as flash notices

I am quite sure someone has already found this simple solution, but when I poked around, I couldn't find it.

Here is my snippet to print out the error messages resulting from a validation as a flash notice:

  if @user.save
    flash[:'notice'] = "New user saved successfully."
  elsif !@user.errors.empty?
    flash[:'notice'] = "Could not save new user: "
        << @user.errors.full_messages.join("; ")
  end
posted
tags: