Skip to content

Instantly share code, notes, and snippets.

@foliwe
foliwe / book.rb
Last active March 3, 2017 21:36
Advanced search Form
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
@foliwe
foliwe / searh.rb
Created March 3, 2017 20:57
search
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?
<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>
@foliwe
foliwe / home.coffe
Created March 24, 2017 10:21
Jquery
$(document).on "turbolinks:load", ->
$('#menu_toggle').click ->
$('#menu_side').addClass('visible')
def index
@recipes = Recipe.all.limit(3)
end
@foliwe
foliwe / _task.html.erb
Last active April 20, 2018 11:51
Project Managment
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>