Skip to content

Commit

Permalink
fix: added default implementation of topic_search helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Waishnav committed Aug 23, 2024
1 parent c36c160 commit 1d6a211
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 7 additions & 0 deletions app/helpers/simple_discussion/forum_threads_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ def parent_layout(layout)
output = render(template: "layouts/#{layout}")
self.output_buffer = ActionView::OutputBuffer.new(output)
end

# simple sql query implementation of basic_search, this helper method can be complex as it you wanted it to be
def topic_search(query)
ForumThread.joins(:forum_posts)
.where("forum_threads.title LIKE :query OR forum_posts.body LIKE :query", query: "%#{query}%")
.distinct
end
end
1 change: 1 addition & 0 deletions simple_discussion.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Gem::Specification.new do |spec|
spec.add_dependency "language_filter", ">= 0.3.01"
spec.metadata["rubygems_mfa_required"] = "true"
end

6 changes: 0 additions & 6 deletions test/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
module ApplicationHelper
# simple sql query implementation of basic_search, this helper method can be complex as it you wanted it to be
def topic_search(query)
ForumThread.joins(:forum_posts)
.where("forum_threads.title LIKE :query OR forum_posts.body LIKE :query", query: "%#{query}%")
.distinct
end
end

0 comments on commit 1d6a211

Please sign in to comment.