Reputation: 229
So i have searchkick working ( i can see the params displayed with byebug)
However, I'm wanting it to show a results page, ( i do need to create the search results page which im currently doing)
I havent a clue on how to link serch kick up so it spits out the results of the search (pagenated) rather than not showing anything
Heres what i have so far, I have the search engine on the homepage.
/pages/home.html.erb
<%= form_tag search_events_path, class: "form-inline", remote: true, method: :get do %>
<div class="input-group input-group-lg">
<%= text_field_tag :search, params[:search], class: "form-control", autocomplete: "off" %>
<div class="input-group-btn">
<%= submit_tag "Search", class: "btn btn-primary" %>
</div>
</div>
<% end %>
This is in my routes
get 'search_events' => 'newevents#search', as: 'search_events'
my controller is this
def search
events = Newevent.search params[:search]
render :json => events.to_json
end
And my model just has searchkick
inside
I'm wanting to have the search results show on a page inside the event folder called results.html.erb. Any help would be greatly appreciated!
Thanks,
Please be gentle, I've not been working with rails long. (enough to have read a couple of books thats how i have gotten this far haha!)
Upvotes: 0
Views: 519
Reputation: 11275
So you want newevents#search
to render results.html.erb
inside the app/views/events
folder. Here you are:
def search
@events = Newevent.search params[:search]
render 'events/results'
end
Upvotes: 1