Fulltext search for packages works
This commit is contained in:
parent
8df03296e9
commit
acd47f66d7
3 changed files with 17 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
class PackagesController < ApplicationController
|
class PackagesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@packages = Package.order('name').first(20)
|
query = '%'+params[:search]+'%'
|
||||||
|
@packages = Package.where("description like ? or name like ?", query, query).order('name').first(20)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_screenshots
|
def with_screenshots
|
||||||
|
|
|
||||||
|
|
@ -1 +1,14 @@
|
||||||
<h1>Hello, Rails!</h1>
|
<h1>Hello, Rails!</h1>
|
||||||
|
|
||||||
|
<h1>Search for a package/description:</h1>
|
||||||
|
<form action="/packages" method="get">
|
||||||
|
<div>
|
||||||
|
<input id="search" name="search" type="text" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<%= form_tag("/packages", method: "get") do %>
|
||||||
|
<%= text_field_tag :search, '', autofocus: true, placeholder: 'Search criteria...' %>
|
||||||
|
<%= submit_tag "Search" %>
|
||||||
|
<% end %>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue