Project

General

Profile

Own Plugin searchable

Added by Pascal B over 8 years ago

Hi there,

I have build an plugin for store customer data. Now I want to make the tables search able via the global redmine search. But when I fire the search the Server gives me an Error 500 back.

init.rb


[..]
Redmine::Search.map do |search|
search.register :companies
end
[..]

companies_controller.rb


[..]
default_search_scope :companies
[..]

company.rb


[..]
acts_as_searchable :columns => ["#{table_name}.company_name"], :project_key => nil, :date_column => nil
[..]

And the Error from logging File:

Mysql2::Error: Unknown column 'created_on' in 'field list': SELECT DISTINCT created_on, `customers_companies`.`id` FROM `customers_companies` WHERE (projects.status <> 9) AND (((customers_companies.company_name LIKE '%thynk%')))  ORDER BY `customers_companies`.`created_on` DESC, `customers_companies`.`id` DESC)

So I make an new migration and add the column 'created_on' to the table customers_companies and then I become the following error:

Mysql2::Error: Unknown column 'projects.status' in 'where clause': SELECT DISTINCT created_on, `customers_companies`.`id` FROM `customers_companies` WHERE (projects.status <> 9) AND (((customers_companies.company_name LIKE '%thynk%')))  ORDER BY `customers_companies`.`created_on` DESC, `customers_companies`.`id` DESC):

So my question, how maybe I can define the search query and why define redmine this query with an assocition to projects?

Thanks and bye