I have Searchkick setup and and everything works. How would i get tags added through acts_as_taggable to show up in the search? So if a user searches for a tag it will show up in the results.
Routes.rb
Rails.application.routes.draw do
root 'links#index'
resources :tag
resources :links do
collection do
get 'search'
end
end
end
Controller Search Action
def search
if params[:search].present?
@links = Link.search(params[:search], page: params[:page], per_page: 15 )
else
@links = Link.all
end
end
Search.html.erb View
<%= render 'shared/tagcloud' %>
<%= will_paginate @link %>
<div id="links-wrapper">
<%= render partial: "shared/link", collection: @links %>
</div>
Solved! I had to add this to my Links Model File:
def search_data
attributes.merge(
tags_name: tags.map(&:name)
)
end