Parsing Errors on Command Line
find . -name \*.php \! -exec php -l {} \;
11341 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
find . -name \*.php \! -exec php -l {} \;
e = assert_raise(RuntimeError) { my_code_that_raises } assert_match(/Error message here/i, e.message)..
error_messages_for ‘object’
# _form.rhtml <p><label for="code_project_name">Name</label> <%= text_field ‘code_project’, ‘name’ %> <%= error_for ‘code_project’, ‘name’ %></p>
def display_standard_flashes(message = 'There were some problems with your submission:') if flash[:notice] flash_to_display, level = flash[:notice], 'notice' elsif flash[:warning] flash_to_display, level = flash[:warning], 'warning' elsif flash[:error] level = 'error' if flash[:error].instance_of? ActiveRecord::Errors flash_to_display = message flash_to_display << activerecord_error_list(flash[:error]) else flash_to_display = flash[:error] end else return end content_tag 'div', flash_to_display, :class => "flash #{level}" end def activerecord_error_list(errors) error_list = '<ul class="error_list">' error_list << errors.collect do |e, m| "<li>#{e.humanize unless e == "base"} #{m}</li>" end.to_s << '</ul>' error_list end
class ActiveRecord::Errors def to_xml(options = {}) options[:indent] ||= 2 options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]), :root => "errors" }) options[:builder].instruct! unless options.delete(:skip_instruct) options[:builder].__send__(options[:root].to_s.dasherize) do |xml| @errors.each do |key, value| xml.__send__(key.to_s.dasherize) do |xm| for message in value xm.message(message) end end end end end end
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| error_style = "background-color: #ffff80" if html_tag =~ /<(input|textarea|select)[^>]+style=/ style_attribute = html_tag =~ /style=['"]/ html_tag.insert(style_attribute + 7, "#{error_style}; ") elsif html_tag =~ /<(input|textarea|select)/ first_whitespace = html_tag =~ /\s/ html_tag[first_whitespace] = " style='#{error_style}' " end html_tag end