我想創建Redmine插件,並在該插件中我想上傳文件或圖像,並在顯示操作中顯示圖像或下載文件。誰能幫我。Redmine如何上傳和下載插件內的文件?
在模型
class UserInformation < ActiveRecord::Base
unloadable
belongs_to :project
acts_as_attachable :view_permission => :view_files,
:edit_permission => :manage_files,
:delete_permission => :manage_files
在控制器
class UserInformationsController < ApplicationController
unloadable
require File.dirname(__FILE__) + '/../../../../app/helpers/attachments_helper'
include AttachmentsHelper
helper :attachments
在new.html.erb
<p> <%= render :partial => 'attachments/form' %></p>
在show.html.erb
<%= link_to_attachments @info, :thumbnails => true %>
你能幫我是正確的方法?
哇這爲我工作。現在我能夠上傳文件,但如何下載文件。我面臨錯誤您無權訪問此頁面。現在看到我按照你的建議添加了模型代碼 –
我最近添加了附件,並且仍然有相同的錯誤 我還沒有弄清楚,但很可能它是通過編輯init.rb中的權限來解決的'文件: ... project_module:your_plugin做 權限:PERMISSION_NAME,{:your_model => [:actions_array]}:公衆=>真正 結束 .... 外觀http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial#Adding-new-permissions –
在添加init權限後面臨同樣的問題。 –