我看不到redmine插件的附件

时间:2016-04-21 08:14:05

标签: ruby-on-rails ruby plugins redmine

我在看到插件中的附件时遇到了问题,它向我显示了以下消息:您无权访问此页面。我使用附件助手上传插件中的内容。这是代码: Init.rb(授予权限)

project_module:plugin_name do

permission :view_attachments, :attachments => [:show, :download, :thumbnail, :upload]

模型类,在我的例子中是Unit.rb

class Unit < ActiveRecord::Base
    belongs_to :project


     acts_as_attachable :view_permission => :view_attachments

units_controller.rb

class UnitsController < ApplicationController 

  helper :attachments
  include AttachmentsHelper     
  menu_item :overviews, :only => [:index, :show, :edit, :new, :update, :create]
  before_filter(:find_project, :authorize, :only => [:index, :show, :edit, :new, :update, :create])

...
def create
    @unit = Unit.new(unit_params)
      if(@unit.save)
      attachments = Attachment.attach_files(@unit, params[:attachments])
   redirect_to(:action => "index")
    flash[:notice] = l(:createMessage)
      else
          render("new")
      end
  end

单位show.html.erb

<%= link_to_attachments @unit  %>

P.S-当我删除attachments_controller中的这部分代码时,我可以看到我的附件,见下文:

before_filter :file_readable, :read_authorize, :only => [:show, :download, :thumbnail]

read_authorize action:

def read_authorize
    @attachment.visible? ? true : deny_access
  end

1 个答案:

答案 0 :(得分:0)

我认为,您不应重新启动附件权限。 尝试使用Unit的特殊许可:

  

acts_as_attachable:view_permission =&gt; :view_unit