I am creating an application in which I would like to use a simple search to search by the name of the object, and the tags (using act_as_taggable_on) in one search
I can build either, but not both, and I'm finally trying to figure it out.
To search using tags, I use:
@post = Post.tagged_with(params[:search])
To search for an object, I use:
@post = Post.search(params[:search])
And I wrote a method called search in the Post model as follows:
def self.search(search) if search where('question LIKE ?', "%#{search}%") else scoped end end
Any idea how to combine these two queries? Any attempts have so far failed, mainly because my Post model does not have a “tag” column, etc.
source share