我正在尝试使用本文之后的新功能扩展存储库控制器: http ://www.redmine.org/projects/redmine/wiki/Plugin_Internals
一切似乎都正常,但是当我单击调用我的扩展功能的按钮时,我收到此错误:
过滤器链停止为:授权渲染或重定向完成 403 Forbidden in 5ms (ActiveRecord: 2.0ms)
按照我的相关代码。
在 lib/client 中创建的 client.rb
require_dependency 'repositories_controller'
module RepositoriesPatch
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
def exec_client
[...]
end
end
end
Repository.send(:include, RepositoriesPatch)
初始化.rb
#encoding: utf-8
require_dependency 'client/client'
Redmine::Plugin.register :gerar_versao_projeto do
name 'Gerar Versão Projeto'
[...]
project_module :repository do
permission :view_repository, :repository => :exec_client
end
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
end
路线.rb
match '/projects/:id/repository', :action => 'exec_client', :controller => 'repositories', :via => :post
在我看来,我调用函数 exec_client 如下所示:
<%= button_to_function l(:gerar_build_project), remote_function(:action => 'exec_client', :controller => 'repositories')%>
如果有人感兴趣,下面是完整的日志错误:
Started POST "/projects/teste1/repository" for 127.0.0.1 at 2013-07-19 16:51:53 -0300
Processing by RepositoriesController#exec_client as JS
Parameters: {"authenticity_token"=>"9JifnciRmiVCbf5uFWWGmSeePp4m0IM74UR10kGemHA=", "id"=>"teste1"}
←[1m←[35m (0.0ms)←[0m SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings`
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` = 1 AND (us
ers.status = 1) LIMIT 1←[0m
←[1m←[35mProject Load (0.0ms)←[0m SELECT `projects`.* FROM `projects` WHERE `projects`.`identifier` = 'teste1' LIMIT 1
←[1m←[36mRepository Load (0.0ms)←[0m ←[1mSELECT `repositories`.* FROM `repositories` WHERE `repositories`.`project_id` = 1 AND (is_default = 1)
LIMIT 1←[0m
←[1m←[35mEnabledModule Load (0.0ms)←[0m SELECT name FROM `enabled_modules` WHERE `enabled_modules`.`project_id` = 1
Filter chain halted as :authorize rendered or redirected
Completed 403 Forbidden in 6ms (ActiveRecord: 0.0ms)
怎么了?