diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 02910d2..f9fba27 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -10,7 +10,13 @@ class BooksController < ApplicationController end 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]) @title = "Books" respond_to do |format| diff --git a/app/views/layouts/_filter.html.erb b/app/views/layouts/_filter.html.erb index c9a2247..33f301e 100644 --- a/app/views/layouts/_filter.html.erb +++ b/app/views/layouts/_filter.html.erb @@ -5,8 +5,16 @@ <% end %>
- <%= yield(:latest_filter) %> <%= render'layouts/initials' %> <%= render'layouts/perpage' %> + <%= yield(:latest_filter) %> + <%= form_tag(method: :get, remote: true) do %> +
+ + <%= button_tag "Seach", class: "btn btn-default" %> + + <%= text_field_tag(:s, nil, placeholder: "Search for...", class: "form-control") %> +
+ <% end %>