From 3d5f3ab66886e7caf1a4c6b67f02239fdc1bdaf3 Mon Sep 17 00:00:00 2001 From: Aboobacker MK Date: Sat, 4 Nov 2017 00:32:00 +0530 Subject: [PATCH] Run action controller load hook only once Rails execute `action_controller` onload hooks for Both ActionController::Base and ActionController::API. Rails [introduced](https://github.com/rails/rails/pull/30045) `has_one` option to limit executions to one This will fix #173 for rails 5.1.4 and above --- .travis.yml | 2 +- lib/merit.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb1b2692..9a8c956d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ rvm: env: - RAILS_VERSION=5.0.3 - - RAILS_VERSION=5.1 + - RAILS_VERSION=5.1.1 diff --git a/lib/merit.rb b/lib/merit.rb index 14095709..8162d872 100644 --- a/lib/merit.rb +++ b/lib/merit.rb @@ -82,7 +82,7 @@ class Engine < Rails::Engine initializer 'merit.controller' do |app| extend_orm_with_has_merit require_models - ActiveSupport.on_load(:action_controller) do + ActiveSupport.on_load(:action_controller, run_once: true) do begin # Load app rules on boot up Merit::AppBadgeRules = Merit::BadgeRules.new.defined_rules