Ruby on rails 如何在Redmine岩芯改造中使用前置过滤器

Ruby on rails 如何在Redmine岩芯改造中使用前置过滤器,ruby-on-rails,redmine,redmine-plugins,Ruby On Rails,Redmine,Redmine Plugins,我在redmine上创建了一个插件,它修改了RepositoryController的核心 我在这个控制器中添加了一个带有新函数的补丁,我可以根据角色权限调用这个函数 但是为了正确设置权限,我需要在为我的新功能使用授权(:authorize)进行筛选之前配置 问题是在我的补丁中添加before_过滤器不起作用,我不知道最好的方式是什么。我的代码如下: client.rb module RepositoriesPatch require_dependency 'repositories_c

我在redmine上创建了一个插件,它修改了RepositoryController的核心

我在这个控制器中添加了一个带有新函数的补丁,我可以根据角色权限调用这个函数

但是为了正确设置权限,我需要在为我的新功能使用授权(
:authorize
)进行筛选之前配置

问题是在我的补丁中添加before_过滤器不起作用,我不知道最好的方式是什么。我的代码如下:

client.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
init.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

必须在类内按如下方式计算过滤前的

def self.included(base)
    base.send(:include, InstanceMethods)
    base.class_eval do
        unloadable
        before_filter :authorize, :only => :exec_client
    end
end

必须在类内按如下方式计算过滤前的

def self.included(base)
    base.send(:include, InstanceMethods)
    base.class_eval do
        unloadable
        before_filter :authorize, :only => :exec_client
    end
end

必须在类内按如下方式计算过滤前的

def self.included(base)
    base.send(:include, InstanceMethods)
    base.class_eval do
        unloadable
        before_filter :authorize, :only => :exec_client
    end
end

必须在类内按如下方式计算过滤前的

def self.included(base)
    base.send(:include, InstanceMethods)
    base.class_eval do
        unloadable
        before_filter :authorize, :only => :exec_client
    end
end

作为Rails 4的旁白,它引入了“before_action”,随着时间的推移,它显然将取代“before_filter”


Pierre在Rails 4中作为旁白引入了“before_action”,随着时间的推移,它显然将取代“before_filter”


Pierre在Rails 4中作为旁白引入了“before_action”,随着时间的推移,它显然将取代“before_filter”


Pierre在Rails 4中作为旁白引入了“before_action”,随着时间的推移,它显然将取代“before_filter”


皮埃尔的作品完美而流畅。谢谢。工作非常顺利。谢谢。工作非常顺利。谢谢。工作非常顺利。谢谢