README.md in exception-track-0.1.2 vs README.md in exception-track-0.1.3

- old
+ new

@@ -3,10 +3,12 @@ Tracking exceptions for Rails application store them in database. This gem is base on [exception_notification](https://github.com/smartinez87/exception_notification/). +[中文介绍和使用说明](https://ruby-china.org/topics/32325) + [![Gem Version](https://badge.fury.io/rb/exception-track.svg)](https://badge.fury.io/rb/exception-track) [![Build Status](https://travis-ci.org/rails-engine/exception-track.svg)](https://travis-ci.org/rails-engine/exception-track) [![Code Climate](https://codeclimate.com/github/rails-engine/exception-track/badges/gpa.svg)](https://codeclimate.com/github/rails-engine/exception-track) [![codecov.io](https://codecov.io/github/rails-engine/exception-track/coverage.svg?branch=master)](https://codecov.io/github/rails-engine/exception-track?branch=master) [![](http://inch-ci.org/github/rails-engine/exception-track.svg?branch=master)](http://inch-ci.org/github/rails-engine/exception-track?branch=master) ![2017-02-17 12 35 18](https://cloud.githubusercontent.com/assets/5518/23052599/8e267c02-f50d-11e6-8d6e-cef0cc1991b7.png) ## Installation @@ -57,20 +59,36 @@ You can config [exception_notification](https://github.com/smartinez87/exception_notification/) by itself's way, more documentations please visit: https://github.com/smartinez87/exception_notification/ -## Router admin authenticate for Devise +## Router admin authenticate -config/router.rb +```rb +# lib/admin_constraint.rb +class AdminConstraint + def matches?(request) + return false if !request.session[:user_id] + user = User.find(request.session[:user_id]) + user && user.admin? + end +end +# config/router.rb +require 'admin_constraint' +mount ExceptionTrack::Engine => "/exception-track", constraints: AdminConstraint.new +``` + +**With Devise** + ```rb +# config/router.rb authenticate :user, ->(u) { u.admin? } do mount ExceptionTrack::Engine => "/exception-track" end ``` -https://github.com/plataformatec/devise/wiki/How-To:-Define-resource-actions-that-require-authentication-using-routes.rb +More examples: [Sidekiq Web Document](https://github.com/mperham/sidekiq/wiki/Monitoring#authentication) ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).