Skip to content

Commit 1d6a211

Browse files
committed
fix: added default implementation of topic_search helper
1 parent c36c160 commit 1d6a211

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

app/helpers/simple_discussion/forum_threads_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,11 @@ def parent_layout(layout)
2525
output = render(template: "layouts/#{layout}")
2626
self.output_buffer = ActionView::OutputBuffer.new(output)
2727
end
28+
29+
# simple sql query implementation of basic_search, this helper method can be complex as it you wanted it to be
30+
def topic_search(query)
31+
ForumThread.joins(:forum_posts)
32+
.where("forum_threads.title LIKE :query OR forum_posts.body LIKE :query", query: "%#{query}%")
33+
.distinct
34+
end
2835
end

simple_discussion.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ Gem::Specification.new do |spec|
2929
spec.add_dependency "language_filter", ">= 0.3.01"
3030
spec.metadata["rubygems_mfa_required"] = "true"
3131
end
32+
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
module ApplicationHelper
2-
# simple sql query implementation of basic_search, this helper method can be complex as it you wanted it to be
3-
def topic_search(query)
4-
ForumThread.joins(:forum_posts)
5-
.where("forum_threads.title LIKE :query OR forum_posts.body LIKE :query", query: "%#{query}%")
6-
.distinct
7-
end
82
end

0 commit comments

Comments
 (0)