Hi I have a post model that :has_many :reply, when using searchlogic, doing Post.reply_content_like(“search”), returns a result for every reply under that post, I only want it to return once. Anyone know a way to solve this
Hi I have a post model that :has_many :reply, when using searchlogic, doing Post.reply_content_like(search),
Share
Searchlogic returns an array of Posts matching your criteria, just as if you used an ActiveRecord
find. If you only want to get one result, well, which one? The first? The last?If you want to get the unique, matched column values, you could do
Post.reply_content_like("search").collect(&:reply_content).uniqor if you just want the first Post
Post.reply_content_like("search").first