1. index.html
  2. <%= form_tag tours_path, method: :get do %>
  3. <p>
  4. <%= text_field_tag :query %>
  5. <%= select_tag "engine", options_for_select(["elastic", "sphinx"]) %>
  6. <%= submit_tag "Search", name: nil, class: "btn btn-mini btn-success" %>
  7. <br>
  8. Name: <%= text_field_tag :name %><br>
  9. Cost: from <%= text_field_tag :cost_from %> to <%= text_field_tag :cost_to %><br>
  10. Direction: <%= text_field_tag :direction %><br>
  11. Country: <%= text_field_tag :country %><br>
  12. <% end %>
  13. torus_controller.rb
  14. class ToursController < ApplicationController
  15. def index
  16. if params[:engine] == "elastic"
  17. @tours = Tour.tire.search(params[:query], load: true)
  18. elsif params[:engine] == "sphinx"
  19. @tours = Tour.search(params[:query])
  20. else
  21. @tours = Tour.all
  22. end
  23. end
  24. def show
  25. @tour = Tour.find(params[:id])
  26. end
  27. end
Comments powered by Disqus