Skip to content

Commit

Permalink
Capitalizing only first letter of error message.
Browse files Browse the repository at this point in the history
There can be sentences in error messages and they should be displayed proper
- with great letter after fullstop.
  • Loading branch information
Ania committed Dec 16, 2010
1 parent d1f0ed7 commit b20771c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/invoices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create
request.xhr? ? "" : redirect(resource(:invoices))
else
if request.xhr?
render_failure @invoice.errors.full_messages.reject { |m| m =~ /integer/ }.join(", ").capitalize
render_failure smart_errors_format(@invoice.errors)
else
render :index
end
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,11 @@ def format_number(number, options = {})
end
end

def smart_errors_format(errors)
message = errors.full_messages.reject { |m| m =~ /integer/ }.join(", ").split(' ')
message.first.capitalize unless message.empty?
message.join(' ')
end

end
end # Merb

0 comments on commit b20771c

Please sign in to comment.