【问题标题】:I cant see my attachments from redmine plugin我无法从 redmine 插件中看到我的附件
【发布时间】:2016-04-21 08:14:04
【问题描述】:

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

project_module :plugin_name 做

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- 当我在附件控制器中删除这部分代码时,我可以看到我的附件,见下文:

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

read_authorize 操作:

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

【问题讨论】:

    标签: ruby-on-rails ruby plugins redmine


    【解决方案1】:

    我认为,您不应该重新初始化附件权限。 尝试使用 Unit 的特殊权限:

    acts_as_attachable :view_permission => :view_unit

    【讨论】:

    • 我试过了,但它不起作用,我把它们都做了:public => true 但仍然没有给我附件的权限
    猜你喜欢
    • 2014-02-12
    • 1970-01-01
    • 2020-02-26
    • 2018-01-30
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 2012-05-25
    • 1970-01-01
    相关资源
    最近更新 更多