I am using acts-as-taggable-on gem
i use single field to search by tag_name and user_name
User.rb
class User < ActiveRecord::Base
acts_as_taggable
attr_accessor: :user_name, :age, :country, tag_list
scope :tagged_with, lambda { |tag|
{
:joins => "INNER JOIN taggings ON taggings.taggable_id = user.id\
INNER JOIN tags ON tags.id = taggings.tag_id AND taggings.taggable_type = 'User'",
:conditions => ["tags.name = ?", tag],
:order => 'id ASC'
}
}
def self.search(search)
if search
where('name LIKE ?', "%#{search}%") + tagged_with(search)
else
scoped
end
end
end
But i have pagination issue while getting this as Array and i used "will_paginate/Array" in config/initializer/will_paginate.rb it doesn't work.
Can you help me to add this scopes as ActiveRecord relation to use pagination without issue.
Aucun commentaire:
Enregistrer un commentaire