Book Image

Redmine Plugin Extension and Development

By : Alex Bevilacqua
Book Image

Redmine Plugin Extension and Development

By: Alex Bevilacqua

Overview of this book

Table of Contents (16 chapters)
Redmine Plugin Extension and Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preparing our model


We're going to adapt our KbArticle model so that new articles will be listed in the activity stream of any project with a knowledgebase.

In Chapter 5, Making Models Searchable, we introduced the acts_as_event plugin as a prerequisite to use the acts_as_searchable plugin; it also serves as a prerequisite for acts_as_activity_provider.

If we implement acts_as_activity_provider without acts_as_event and try to load an activity stream, Redmine will crash with a NoMethodError exception:

NoMethodError (undefined method `event_datetime' for #<KbArticle:0x000000042b9428>)

The example we provided in the previous chapter is being cited here for continuity:

class KbArticle < ActiveRecord::Base
  # ...
  
  acts_as_event :datetime    => :updated_at,
                :description => :summary,
                :title => Proc.new { |o| "#{l(:label_title_articles)} ##{o.id} - #{o.title}" },
                :url   => Proc.new { |o| { :controller => 'articles', 
     ...