I'm currently developping a redmine plugin, and I'd like to have the actions made with the plugin displayed in the activity stream and I'd also like to be able to search among the objects created by my plugin. I followed Alex Bevilacque's tutorial, very carefully. If you have any clue on what I am doing wrong, it would be great!
Everything is about "prestations".
I've got this to migrate my db:
class CreatePrestations < ActiveRecord::Migration
def change
create_table :prestations do |t|
t.column :nom, :string, :null => false
t.column :description, :text
t.column :project_id, :int, :default => 0
t.column :author_id, :int, :default => 0, :null => false
t.timestamps
end
end
end
And this model:
class Prestation < ActiveRecord::Base
belongs_to :project
validates_presence_of :nom
acts_as_searchable :columns => [ "#{table_name}.nom", "#{table_name}.description"],
:scope => preload(:project),
:date_column => "created_at"
acts_as_event :title => Proc.new { |o| "#{l(:label_title_prestation)} ##{o.id} - #{o.nom}"},
:description => :description,
:datetime => :updated_at,
:type => Proc.new { |o| 'prestation-' + (o.new_status ? 'add' : 'edit') },
:url => Proc.new { |o| {:controller => 'prestations', :action => 'show', :id => o.id, :project_id => o.project} }
acts_as_activity_provider :scope => preload(:project),
:author_key => :author_id,
:type => 'prestations',
:timestamp => :updated_at,
:permission => :activity_presta
end
And this at the very beginning of my init.rb:
Rails.configuration.to_prepare do
Redmine::Activity.register :prestations
Redmine::Search.available_search_types << 'prestations'
end
When I click on "search", I can search among every normal redmine fields, but not my "prestations", and when I look at the activity stream, I've got this:
ActiveRecord::StatementInvalid (SQLite3::SQLException: no such column: projects.id: SELECT "prestations".* FROM "prestations" WHERE (updated_at BETWEEN '2016-05-20' AND '2016-06-19') AND (((projects.id = 1 OR (projects.lft > 1 AND projects.rgt < 2))) AND (projects.status = 1))):
lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb:81:in `find_events'
lib/redmine/activity/fetcher.rb:91:in `block (2 levels) in events'
lib/redmine/activity/fetcher.rb:90:in `each'
lib/redmine/activity/fetcher.rb:90:in `block in events'
lib/redmine/activity/fetcher.rb:89:in `each'
lib/redmine/activity/fetcher.rb:89:in `events'
app/controllers/activities_controller.rb:56:in `index'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
I reseted the database to start a new redmine from scratch, I reloaded the server and changed the token, up to no avail.
I really don't understand why 1) I can't even get the possibility to search among my "prestations" (just having the checkbox would be great) 2) Rails tries to look for "projects.id" which I didn't ask for
Thanks a lot in advance.