我在 redmine 上创建了一个插件,它修改了 RepositoryControler 的核心。
我在这个控制器中添加了一个带有新函数的补丁,我可以根据角色权限调用这个函数。
但要正确设置权限,我需要为我的新功能配置before_filter
授权 ( )。:authorize
问题是因为在我的补丁中添加 before_filter 不起作用,我不知道最好的方法是什么。按照我的代码:
客户端.rb
module RepositoriesPatch
require_dependency 'repositories_controller'
def self.included(base)
base.send(:include, InstanceMethods)
end
end
module InstanceMethods
require_dependency 'repositories_controller'
#I THINK THE BEFORE_FILTER SHOULD BE PLACED HERE, BUT IT DIDN'T WORKED.
# before_filter :authorize, :only => :exec_client (????????)
def exec_client
begin
....
end
end
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
初始化.rb
permission :repositories, :repositories => :exec_client
project_module :repository do
permission :exec, :repository => :exec_client
end
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
settings :default => {'empty' => true}, :partial => 'settings/gerar_versao_configuration'
end