-
-
Save tbuehlmann/83d5e54a4d371b70be4f27618042bedc to your computer and use it in GitHub Desktop.
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
class BooksController < ApplicationController | |
def index | |
@books = Book.all | |
end | |
def search | |
@books = Book.all | |
if params[:price].present? | |
@books = @books.where('price <= ?', params[:price]) | |
end | |
if params[:category].present? | |
@books = @books.where(category_id: params[:category]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment