From a8863a4953c1e9d98b92447021cf0c27987e19b0 Mon Sep 17 00:00:00 2001 From: Ben Li Date: Thu, 29 May 2014 17:09:56 +1000 Subject: [PATCH 1/2] Fix the issue that the widget_id of the first widget intance bleeds into the event handlers of the second widget instance --- lib/apotomo/widget/event_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/apotomo/widget/event_methods.rb b/lib/apotomo/widget/event_methods.rb index ec78378..9a2633a 100644 --- a/lib/apotomo/widget/event_methods.rb +++ b/lib/apotomo/widget/event_methods.rb @@ -8,7 +8,7 @@ module EventMethods included do after_initialize do self.class.responds_to_event_options.each do |args| - type, options = args[0], args[1] || {} + type, options = args[0], (args[1] || {}).clone target = self if target_id = options[:passing] From 3e2d5068856933882fd2da655bf9aceb363d3352 Mon Sep 17 00:00:00 2001 From: Ben Li Date: Tue, 18 Feb 2020 15:47:15 +1100 Subject: [PATCH 2/2] do not load apotomo routes in Rails 5.1 and above as dynamic :controller segment is now deprecated --- lib/apotomo/railtie.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/apotomo/railtie.rb b/lib/apotomo/railtie.rb index c144bdc..106ae34 100644 --- a/lib/apotomo/railtie.rb +++ b/lib/apotomo/railtie.rb @@ -6,10 +6,14 @@ class Railtie < ::Rails::Railtie load "apotomo/apotomo.rake" end - # As we are a Railtie only, the routes won't be loaded automatically. Beside that, we want our - # route to be the very first (otherwise #resources might supersede it). - initializer 'apotomo.prepend_routes', :after => :add_routing_paths do |app| - app.routes_reloader.paths.unshift(File.dirname(__FILE__) + "/../../config/routes.rb") + # In Rails 5.1, a dynamic :controller segment in a route is deprecated. + # The routes for each controller have to be added in routes.rb. + if ::ActiveRecord.gem_version < ::Gem::Version.new("5.1.0.beta1") + # As we are a Railtie only, the routes won't be loaded automatically. Beside that, we want our + # route to be the very first (otherwise #resources might supersede it). + initializer 'apotomo.prepend_routes', :after => :add_routing_paths do |app| + app.routes_reloader.paths.unshift(File.dirname(__FILE__) + "/../../config/routes.rb") + end end # Include a lazy loader via has_widgets.