This file contains 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 Book < ApplicationRecord | |
belongs_to :category | |
def self.search(params) | |
books = Book.all | |
books = books.where("title LIKE '?'",params[:search]) if params[:search].present? | |
books = books.where(category_id: params[:category]).where("price <= ?", params[:price]) | |
end | |
end |
This file contains 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 | |
if params[:price].present? && params[:category].present? | |
@books = Book.where(category_id: params[:category]).where("price <= ?", params[:price]) | |
elsif | |
params[:category].present? |
This file contains 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
<div class="container"> | |
<div class="d-flex flex-column justify-content-center main" > | |
<div class="blue"> | |
<h3 class ="text-center">Blue Box</h3> | |
</div> | |
</div> | |
</div> |
This file contains 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
$(document).on "turbolinks:load", -> | |
$('#menu_toggle').click -> | |
$('#menu_side').addClass('visible') |
This file contains 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
def index | |
@recipes = Recipe.all.limit(3) | |
end | |
This file contains 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
Views/tasks/_task.html.erb | |
<tr> | |
<td><%= task.name%></td> | |
<td> | |
<%= link_to 'Destroy ', [task.project, task], | |
method: :delete, | |
data: { confirm: 'Are you sure?' } %> | |
</td> | |
</tr> |