Skip to content

Instantly share code, notes, and snippets.

@basicavisual
Created July 24, 2017 17:19
Show Gist options
  • Save basicavisual/8fc8fe0cfed74e7779ffc6e08d62e99a to your computer and use it in GitHub Desktop.
Save basicavisual/8fc8fe0cfed74e7779ffc6e08d62e99a to your computer and use it in GitHub Desktop.
class Fiscal < ApplicationRecord
def self.search(search)
if search
where(["nombre LIKE ?", "%#{search}%"])
else
last(5)
end
end
end
class FiscalsController < ApplicationController
def index
@fiscals = Fiscal.search(params[:search])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment