search WIP
This commit is contained in:
parent
afa911284c
commit
e47b68ff0e
@ -10,7 +10,13 @@ class BooksController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@books = Book.where(initial_filter).order(sort_col)
|
filters = initial_filter
|
||||||
|
if params[:s]
|
||||||
|
filters[0] << " AND sort like ?"
|
||||||
|
filters.push("%#{params[:s]}%")
|
||||||
|
end
|
||||||
|
puts filters
|
||||||
|
@books = Book.where(filters).order(sort_col)
|
||||||
.paginate(page: params[:page], per_page: session[:current_per_page])
|
.paginate(page: params[:page], per_page: session[:current_per_page])
|
||||||
@title = "Books"
|
@title = "Books"
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -5,8 +5,16 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body collapse" id="filterContent">
|
<div class="panel-body collapse" id="filterContent">
|
||||||
<%= yield(:latest_filter) %>
|
|
||||||
<%= render'layouts/initials' %>
|
<%= render'layouts/initials' %>
|
||||||
<%= render'layouts/perpage' %>
|
<%= render'layouts/perpage' %>
|
||||||
|
<%= yield(:latest_filter) %>
|
||||||
|
<%= form_tag(method: :get, remote: true) do %>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<%= button_tag "Seach", class: "btn btn-default" %>
|
||||||
|
</span>
|
||||||
|
<%= text_field_tag(:s, nil, placeholder: "Search for...", class: "form-control") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user