ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
"undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0
Added by Paweł O at 2011-12-10 05:47 am
I am doing installation of some usefull plugins that I used succesfully in Redmine 1.0.5 into Chiliproject 2.5.0. One of the plugins is ScreenshotPaste which I actually get from git://github.com/merpati09/Screenshot-Paste-Plugin.git.
During bundle exec rake db:migrate RAILS_ENV=production
I get an error:
(in /usr/share/chiliproject) rake aborted! undefined method `attach_files' for class `ApplicationController' Tasks: TOP => db:migrate => environment (See full trace by running task with --trace)
This seems to case that has been reported here on plugin original issues page) and the answer from developer was "You're using 0.9.trunk, right? Looks like the attachment methods there are different from what's in 0.9.4. I think we'll be able to provide an update with the next stable release (we do live on them, not on trunk)."
And since the plugin installation worked in Chiliproject 2.4.0, so the question is if there some code changes between versions concerning attachment methods that could cause such problem. And if not what else could be a problem (the code of plugin seem not to be changed in the meantime).
Replies (6)
RE: "undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0 - Added by Paweł O at 2011-12-10 05:51 am
Here is also output from bundle exec rake db:migrate RAILS_ENV=production --trace
:
(in /usr/share/chiliproject) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `attach_files' for class `ApplicationController' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/core_ext/module/aliasing.rb:33:in `alias_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain' /usr/share/chiliproject/vendor/plugins/Screenshot-Paste-Plugin/init.rb:40:in `send' /usr/share/chiliproject/vendor/plugins/Screenshot-Paste-Plugin/init.rb:40:in `included' /usr/share/chiliproject/vendor/plugins/Screenshot-Paste-Plugin/init.rb:61:in `include' /usr/share/chiliproject/vendor/plugins/Screenshot-Paste-Plugin/init.rb:61:in `send' /usr/share/chiliproject/vendor/plugins/Screenshot-Paste-Plugin/init.rb:61 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:182:in `call' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:182:in `evaluate_method' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:166:in `call' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `each' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `send' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `run' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:276:in `run_callbacks' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/dispatcher.rb:51:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks' /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:631:in `prepare_dispatcher' /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:185:in `process' /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in `send' /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in `run' /usr/share/chiliproject/config/environment.rb:39 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require' /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/tasks/misc.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/bin/rake:33 /usr/lib/ruby/gems/1.8/bin/rake:19:in `load' /usr/lib/ruby/gems/1.8/bin/rake:19 Tasks: TOP => db:migrate => environment
RE: "undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0 - Added by Felix Schäfer at 2011-12-10 01:28 pm
There haven't been changes between 2.4.0 and 2.5.0 I could see, but I think dashes in plugin names and/or the directory they are installed in made problems, could you make sure the names of the directories are correct?
RE: "undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0 - Added by Eric Davis at 2011-12-10 09:41 pm
undefined method `attach_files' for class `ApplicationController'
This is a bug in the plugin. In 0fd7e2d696cf2d9 from 2010-03-02 the attach_files
method was moved from ApplicationHelper to Attachment. This happened before we forked from Redmine so this problem should also occur in all versions of ChiliProject as well as recent versions of Redmine.
I don't know how to fix it, since the main code in the plugin is in the RedmineScreenshotPaste
module would would need to be rewritten.
Eric Davis
RE: "undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0 - Added by Paweł O at 2011-12-11 09:05 pm
The same error has been reported on Knowledgbase plugin forum page.
Someone there suggests:
Change
attach_files
to
Attachment.attach_files
in your code and dont forget to check if
helper :attachments include AttachmentsHelper
exists in here. and there knowledgebase plugin developer writes that did a quick fix. So I looked into knowledgbase plugin code and found a file
app/controllers/articles_controller.rb
where the above mentioned lines are:
- from the first line of the file
class ArticlesController < KnowledgebaseController unloadable helper :attachments include AttachmentsHelper include FaceboxRender
and the very end of the file####### private ####### # Abstract attachment method to resolve how files should be attached to a model. # In newer versions of Redmine, the attach_files functionality was moved # from the application controller to the attachment model. def attach(target, attachments) if Attachment.respond_to?(:attach_files) Attachment.attach_files(target, attachments) render_attachment_warning_if_needed(target) else attach_files(target, attachments) end end end
I am not software developer but I looked also into the RedmineScreenshotPaste and found out that there is only one init.rb file and it is not more than 62 line.
So maybe you guys would not mind having a quick look into it and suggest what could be done based on the above suggestions and quotes - I attach init.rb file.
init.rb - init.rb file fron ScreenshotPaste plugin (1.5 kB)
RE: "undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0 - Added by Paweł O at 2012-01-21 02:55 pm
I have noticed that on ScreenshotPaste plugin page there is newer plugin version 1.1.1 which is release after version 1.1.0 which deals with Refactor: Moved ApplicationController#attach_files to the Attachment model.
So I downloaded 1.1.1 zip packed and used it, but this time with Chiliproject 2.6.0 and it works perfectly:-)
RE: "undefined method `attach_files' for class `ApplicationController'" error during ScreenshotPaste plugin installation with Chiliproject 2.5.0 - Added by Felix Schäfer at 2012-01-29 06:14 pm
Paweł O wrote:
So I downloaded 1.1.1 zip packed and used it, but this time with Chiliproject 2.6.0 and it works perfectly:-)
Good to hear, thanks for reporting :-) Could you also write it up in Plugin_Compatibility if not done already?
(1-6/6)