I am using acts-as-taggable-on gem.
i want to use search both name as well as tags in single search field
my model
class User < ActiveRecord::Base
acts_as_taggable
attr_accessor: :name, :age, :country, tag_list
def self.search(search)
if search
where('name LIKE ?', "%#{search}%")
else
scoped
end
end
end
Controller
class UserAppsController < ApplicationController
def index
@users = User.search(params[:search])
//@users = User.tagged_with(params[:search])
end
end
Help me to solve this.
Aucun commentaire:
Enregistrer un commentaire