Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Integrate Rails callbacks into existing parts of Redmine
- # in init.rb file
- # ---------------
- ~~~ ruby
- require 'redmine'
- # Patches to the Redmine core.
- require 'dispatcher'
- Dispatcher.to_prepare :redmine_kanban do
- require_dependency 'issue'
- # Guards against including the module multiple time (like in tests)
- # and registering multiple callbacks
- unless Issue.included_modules.include? RedmineKanban::IssuePatch
- Issue.send(:include, RedmineKanban::IsstuePatch)
- end
- end
- ~~~
- # in patch file
- # --------------
- ~~~ ruby
- module IssuePatch
- def self.included(base) # :nodoc:
- base.extend(ClassMethods)
- base.send(:include, InstanceMethods)
- # Same as typing in the class
- base.class_eval do
- unloadable # Send unloadable so it will not be unloaded in development
- after_save :update_kanban_from_issue
- after_destroy :remove_kanban_issues
- # Add visible to Redmine 0.8.x
- unless respond_to?(:visible)
- named_scope :visible, lambda {|*args| { :include => :project,
- :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
- end
- end
- end
- ~~~
Add Comment
Please, Sign In to add comment