开发者

Log all broken validations

开发者 https://www.devze.com 2023-03-05 00:16 出处:网络
In my opinion one good way to reduce support time is to predict any problems our users try to report us.

In my opinion one good way to reduce support time is to predict any problems our users try to report us. We already do it using exception notification in Rails. We also have a nice control panel so we can access useful information even before the user types his first question mark.

We want to go one step further and to be able and see any validation errors our users have in our control panel.

As users don´t read dialogs, I´m willing that our softw开发者_如何学Goare have some sort of check engine. Is there any gem or plugin that tracks all validation errors in rails? If not anyone got some tips on writing one?


I don't know about any plugin. To save info about server-side validations, you can very easily put this in your application.rb:

class ActiveRecord::Base
  def valid_with_reporting?(context = nil)
    model_is_valid = valid_without_reporting? context
    MyErrorReport.create(errors) unless model_is_valid
    model_is_valid
  end
  alias_method_chain :valid?, :reporting
end

Where MyErrorReport is your model that stores the given Hash into the database.

The problem with the above solution is that you probably want it to test your usability and user interface design, don't you? And a good user interface usually has a lot of validations client-side only and it would not be so straightforward to test those.

0

精彩评论

暂无评论...
验证码 换一张
取 消