我在redmine上写了一个插件。我将项目和用户权限交给我的插件来访问redmine页面中的按钮。检查轨道上的权限查看
我想要的:只有
显示一个按钮,当用户和项目有权这样做。
下面我的代码:
_navigation.html.erb
<% if ?????? -%> Here is the codition where display or not the button.
<div style="float: left; width: auto; padding-right: 1%">
<%= button_to_function l(:gerar_build_project), remote_function(:action => 'printar', :controller => 'GerarVersao')%>
</div>
<% end -%>
init.rb
permission :view_repository, :gerar_versao_projeto => :exec_client
project_module :gerar_versao_projeto do
permission :view_repository, :gerar_versao_projeto => :exec_client
end
gerar_versao_controller.rb
before_filter :find_project, :authorize, :only => :exec_client
def exec_client
.
.
.
end
private
def find_project
@project = Project.find(params[:project_id])
end
因此,任何人都知道我必须在我的如果,只有当用户或项目有权限时才显示按钮?
谢谢。
呃,这个答案对我来说并不清楚。将该方法添加到哪个模型中?我如何检查用户是否被允许?并与项目?照着做? – kamusett
@ user2195342,它在用户模型上,您可以看到该方法在用户实例上调用。对于任何其他标准,它们是相似的,只需在用户上调用一个方法来查看它是否返回true。 –