I was using this query to fetch a property with nested resources
@property=Property.includes(rooms: [:photos]).where(id: params[:id]).first
The above works. But now I want to use friendly_id. So I tried @property=Property.includes(rooms: [:photos]).friendly.where(id: params[:id]).first
which didnt work. All docs for friendly_id
uses find
instead of where
but here how can I make it work?
You can just filter on the column you use for the friendly_id, usually named slug
Property.includes(roomes: [:photos]).where(slug: params[:id]).first