Skip to content

Instantly share code, notes, and snippets.

@kajatiger
Created November 11, 2016 15:52
Show Gist options
  • Save kajatiger/307054e428d25a99600abf20e108cf90 to your computer and use it in GitHub Desktop.
Save kajatiger/307054e428d25a99600abf20e108cf90 to your computer and use it in GitHub Desktop.
not sure if this is enough to separate development search terms from production search terms
class ProductsController < ApplicationController
before_action :set_product, only: [:show, :edit, :update, :destroy]
# GET /products
# GET /products.json
if RAILS_ENV == "development"
def index
if params[:q]
search_term = params[:q]
@products = Product.where("name LIKE ?", "%#{search_term}%")
else
@products = Product.all
end
end
else
def index
if params[:q]
search_term = params[:q]
@products = Product.where("name ilike ?", "%#{search_term}%")
else
@products = Product.all
end
end
end
def landing_page
@products = Product.limit(3)
search_term = params[:q]
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment