diff --git a/Gemfile.lock b/Gemfile.lock index 3abb910..54a97af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - repost (0.3.0) + repost (0.3.1) GEM remote: https://rubygems.org/ diff --git a/lib/repost/extend_controller.rb b/lib/repost/extend_controller.rb index f0aa689..d2fa759 100644 --- a/lib/repost/extend_controller.rb +++ b/lib/repost/extend_controller.rb @@ -1,18 +1,19 @@ -if defined?(Rails) - class ::ActionController::Base - AUTO_TOKEN_OPTIONS = ['auto', :auto].freeze +if defined?(Rails) && defined?(ActiveSupport) + ActiveSupport.on_load(:action_controller) do + class ::ActionController::Base - def repost(url, params: {}, options: {}) - authenticity_token = form_authenticity_token if AUTO_TOKEN_OPTIONS.include?(options[:authenticity_token]) - render html: Repost::Senpai.perform( - url, - params: params, - options: options.merge({authenticity_token: authenticity_token}.compact) - ).html_safe - end + def repost(url, params: {}, options: {}) + authenticity_token = form_authenticity_token if ['auto', :auto].include?(options[:authenticity_token]) + render html: Repost::Senpai.perform( + url, + params: params, + options: options.merge({authenticity_token: authenticity_token}.compact) + ).html_safe + end - alias :redirect_post :repost + alias :redirect_post :repost + end end end diff --git a/lib/repost/version.rb b/lib/repost/version.rb index 937f3c9..5d19d9a 100644 --- a/lib/repost/version.rb +++ b/lib/repost/version.rb @@ -1,3 +1,3 @@ module Repost - VERSION = "0.3.0" + VERSION = "0.3.1" end