Forums » Development »
Plugin development: undefined method `acts_as_attachable'
Added by General Failure almost 10 years ago
Hi, i needs to a little expand redmine functionality
I want attach files not only for projects and issues, but for time entries too
I created plugin time_entry_attachments, then added 2 patches - TimelogControllerPatch and TimeEntryPatch
In init.rb i included redmine and these patches:
require 'redmine'
require 'timelog_controller_patch'
require 'time_entry_patch'
Methods for TimelogControllerPatch was copied from IssuesController and for TimeEntryPatch from Issue
helper :attachments row in TimelogControllerPatch was replaced for require_dependency 'attachments_helper'
But i don't know what to do with acts_as_attachable ... row in TimeEntryPatch
I gets error message Uncaught exception: undefined method `acts_as_attachable' for TimeEntryPatch:Module when server launching, after it server stops
What and how i must include for acts_as_attachable method acessibility? I can't find :(
Replies (1)
RE: Plugin development: undefined method `acts_as_attachable' - Added by General Failure over 9 years ago
I solved my problem
module TimeEntryPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval dounloadable # Send unloadable so it will not be unloaded in development
acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed # << necessary row was added hereend
end
...
end
All other includes like helper :attachments are adds in self.included method of patches, and require_dependency ... in top of file is not needed for acts_as_attachable, attachments_helper and other changes except including overriding class