Skip to content

Instantly share code, notes, and snippets.

@eLafo
Created April 8, 2010 16:34
Show Gist options
  • Save eLafo/360251 to your computer and use it in GitHub Desktop.
Save eLafo/360251 to your computer and use it in GitHub Desktop.
def object_messages(obj = nil)
if !obj.nil? && !obj.errors.blank?
str_msg = '<div id="message" class="error"><span>' + obj.errors.full_messages.join('<br/>') + '</span></div>'
elsif !flash[:error].blank?
str_msg = '<div id="message" class="error"><span>' + flash[:error] + '</span></div>'
elsif !flash[:notice].blank?
str_msg = '<div id="message" class="notice"><span>' + flash[:notice] + '</span></div>'
elsif !flash[:success].blank?
str_msg = '<div id="message" class="success"><span>' + flash[:success] + '</span></div>'
else
str_msg = ''
end
flash[:error] = ''
flash[:notice] = ''
flash[:success] = ''
return str_msg
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment