Hi, I have the following code. This code executes the same sql query twice. Because images is an associated table of properties.
Is there a way to do only one query, but still have the same result?
(@property.images.first ? @property.images.first.url : "/img/nophoto.jpg")
Extra clarification: the solution should work in 2 scenario's:
- url field for the image is null, but an image exists
- no image exists for that property