Adding has_many to Project
Added by Gary Pickrell about 14 years ago
I'm debugging the advance roadmap plugin (http://ociotec.com/redmine/projects/advanced-roadmap). It is trying to add has_many to ProjectModel. I've never done that myself and the error messages aren't helpful so guidance is useful.
It When I do a migrate I get:
aliasing.rb:33:in `alias_method': undefined method `roadmap' for class `ProjectsController' (NameError) from /home/gap/redmine/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain' from /home/gap/redmine/vendor/plugins/advanced_roadmap/lib/projects_controller_patch.rb:9:in `included'
lib/projects_controller_patch.rb is adding has_many :milestones to Project. It looks like:
require_dependency "projects_controller" module ProjectPatch def self.included(base) base.class_eval do has_many :milestones end end end
It is called from init.rb
... Dispatcher.to_prepare do begin require_dependency "application" rescue LoadError require_dependency "application_controller" end Issue.send(:include, IssuePatch) # Call ProjectPatch Project.send(:include, ProjectPatch) ProjectsController.send(:include, ProjectsControllerPatch) ProjectsHelper.send(:include, ProjectsHelperPatch) Redmine::I18n.send(:include, RedmineI18nPatch) Version.send(:include, VersionPatch) end ...
Replies (2)
RE: Adding has_many to Project - Added by Mischa The Evil about 14 years ago
Gary,
Please take a look at the patch provided by Christoph Plank in note-4 of vendor-issue 352. It fixes what's needed after the more recent refactorings of the ProjectsController
by Eric Davis.
Regards,
Mischa.
RE: Adding has_many to Project - Added by Gary Pickrell about 14 years ago
Thank you Mischa! It works!
-Gary