clear-code / redmine_full_text_search

Full text search for Redmine
MIT License
61 stars 24 forks source link

Change from include to prepend for additional helper method. #56

Closed akiko-pusu closed 6 years ago

akiko-pusu commented 6 years ago

Workaround for clear-code/redmine_full_text_search#55

I'm not sure this workaround is best or not, but I could fix above and related issues.

Step to repoduce

Also I attached simple plugin to reproduce method missing error in case using both plugin.

When using rails console, you could confim IssuesController.helpers.

Here is simple confirmation to call method. In case patch not applied, the method is missing.

irb(main):001:0> IssuesController.helpers.display_score?
NoMethodError: undefined method `display_score?' for #<ActionView::Base:0x00000004adb7c8>
Did you mean?  display_main_menu?

After patch is applied, enabled to call the method.

irb(main):001:0> IssuesController.helpers.display_score?
  Setting Load (0.8ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."name" = $1  ORDER BY "settings"."id" DESC LIMIT 1  [["name", "plugin_full_text_search"]]
=> true

Another workaround

Another workaround to prevent this error is following:

--- a/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb
+++ b/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb
@@ -1,3 +1,4 @@
+<% self.class.send(:include, FullTextSearch::Hooks::SimilarIssuesHelper) -%>
 <% if display_score? %>
   <%
   duration = nil

Include module to AcrtionView::Base class.

Since this plugin is quite useful, I really appreciate if you could consider to fix this problem.

kou commented 6 years ago

Thanks for your report. It's very helpful!

I've pushed a fix in another way: https://github.com/clear-code/redmine_full_text_search/commit/627a861b9911d2241ecef834d5f3685b6b4a7850

akiko-pusu commented 6 years ago

@kou Thanks for considering and fix this issue! Also, I've learned a lot this commit: 627a861