Im haveing problems with seeing the attachments from plugin, it shows me the message : You are not authorized to access this page. I used the attachments helper to upload things in my plugin. Here is the code: Init.rb(giving permissions)
project_module :plugin_name do
permission :view_attachments, :attachments => [:show, :download, :thumbnail, :upload]
The model class, in my case 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
units show.html.erb
<%= link_to_attachments @unit %>
P.S- when i remove this part of code in attachments_controller then i can see my attachments, see below:
before_filter :file_readable, :read_authorize, :only => [:show, :download, :thumbnail]
read_authorize action:
def read_authorize
@attachment.visible? ? true : deny_access
end