Last active
August 26, 2016 04:58
-
-
Save Frank004/08f0e07d3cd9df6418f4c3f739ead592 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag search_path, method: :get do %> | |
<%= text_field_tag :q, nil %> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render partial: "search/form_search" %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# una carpeta en view que diga search y dentro necesitas el index mas el partial del search_form | |
#lista de resultados | |
Productos: | |
<br> | |
<% @products.each do ||%> | |
.... | |
<br> | |
<% end %> | |
Articulos: | |
<br> | |
<% @articles.each do ||%> | |
.... | |
<br> | |
<% end %> | |
Municipios: | |
<br> | |
<% @municipalities.each do ||%> | |
... | |
<br> | |
<% end %> | |
Empresas: | |
<br> | |
<% @enterprises.each do ||%> | |
... | |
<br> | |
<% end %> | |
Categorias: | |
<br> | |
<% @categories.each do ||%> | |
... | |
<br> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get "search" => "search#index" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchController < ApplicationController | |
def index | |
search_word = params[:q] | |
@products = Product.search(name_cont: search_word).result | |
@articles = Article.search(name_cont: search_word).result | |
@municipalities = Municipality.search(name_cont: search_word).result | |
@enterprises = Enterprise.search(name_cont: search_word).result | |
@categories = Category.search(name_cont: search_word).result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment