【发布时间】: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