Class: Supplier

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/supplier.rb

Overview

Schema Information

Table name: suppliers

id         :integer(4)      not null, primary key
name       :string(255)     not null
email      :string(255)
created_at :datetime
updated_at :datetime

Class Method Summary (collapse)

Class Method Details

+ (Array[Variant]) admin_grid(params = {})

paginated results from the admin Supplier grid

Parameters:

  • (Optional params)

Returns:



25
26
27
28
29
30
31
# File 'app/models/supplier.rb', line 25

def self.admin_grid(params = {})
  grid = Supplier
  #grid.includes(:product)
  grid = grid.where("suppliers.name LIKE ?", "#{params[:name]}%")   if params[:name].present?
  grid = grid.where("suppliers.email LIKE ?", "#{params[:email]}%") if params[:email].present?
  grid
end