I'm trying to use the LIKE condition to find similar posts.
Here is my code:
@post = Post.find(params[:id])
@post_gsub = Post.find(params[:id]).name.gsub(/something|something else|something else again/, '')
@related_posts = Post.where("name LIKE '%#{@post_gsub}%'")
But when I pull this into the Rails view, there is currently always one match that shows up, which is the current blog post the user is on. How do I skip that current blog post so that "@related_posts" is only showing unique recommendations and not the post the user is currently on?
Aucun commentaire:
Enregistrer un commentaire