I’ve got an app that deals with websites. There’s a model called “sites”, which has_many pages. The sites model has a column called homepage. The list of pages for each site contains the homepage and additional pages (about, pricing, whatever).
In this post:
Creating scopes based on multiple models, I was able to figure out how to scope the pages model so I could separate the homepage from the additional pages. But I need to modify my the scope further because I noticed that among my additional_pages, I’ve got robots.txt files appearing. I want to exclude those, but I’m not sure how. I appended this:
.where("'robots.txt' <> pages.url[-10,10]")
but no luck. Any suggestions?
You can use this :
.where("pages.url NOT LIKE '%robots.txt'")