Skip to content
Permalink
Browse files

Rails5 support

  • Loading branch information...
suer committed Mar 24, 2018
1 parent b43e757 commit 24c5d3939385d8e1ce966a750d12749b9d7902b9
Showing with 5 additions and 25 deletions.
  1. +1 −5 init.rb
  2. +4 −20 lib/projects_controller_hook.rb
@@ -1,11 +1,7 @@
require 'projects_controller_hook.rb'
require 'recent_project_acccesses_listener'

Rails.configuration.to_prepare do
unless ProjectsController.included_modules.include? RecentProjectAccesses::ProjectsControllerHook
ProjectsController.send(:include, RecentProjectAccesses::ProjectsControllerHook)
end
end
ProjectsController.prepend(RecentProjectAccesses::ProjectsControllerWithSaveRecentProjectAccess)

Redmine::Plugin.register :redmine_recent_project_accesses do
name 'Redmine Recent Project Accesses plugin'
@@ -1,24 +1,8 @@
module RecentProjectAccesses
module ProjectsControllerHook
METHODS = %w(show)

def self.included klass
klass.send(:include, InstanceMethods)
klass.class_eval do
unloadable
METHODS.each do |method|
alias_method_chain method.to_sym, :save_access
end
end
end

module InstanceMethods
METHODS.each do |method|
define_method("#{method}_with_save_access") do
self.send("#{method}_without_save_access")
RecentProjectAccess.save_access(User.current, @project)
end
end
module ProjectsControllerWithSaveRecentProjectAccess
def show
super
RecentProjectAccess.save_access(User.current, @project)
end
end
end

0 comments on commit 24c5d39

Please sign in to comment.
You can’t perform that action at this time.