Also from your example it looks like DM is pulling in the url field as 
an Addressable::URI, so it is probably already fetching all the associated 
records from the DB in order to load them into memory to parse 
into Addressable::URI structures.  If that's the case, then I don't think 
there would be any additional performance overhead from what you originally 
had to just doing

person.photos.all.select{|photo| photo.url.host.downcase == 'amazon.com'}

On Wednesday, August 22, 2012 12:01:05 PM UTC-5, Abe Voelker wrote:
>
> Is this too SQL-ish?
>
> person.photos.all(:conditions => ['"url" ilike ?', "%amazon%"])
>
> On Wednesday, August 22, 2012 11:48:23 AM UTC-5, Neil C wrote:
>>
>> Besides, obviously, a SQL solution.
>>
>> Thanks.
>>
>>
>>
>> On Wednesday, August 22, 2012 12:45:52 PM UTC-4, Neil C wrote:
>>>
>>> I am trying to do the following:
>>>
>>> person.photos.all(:url.like => "amazon").destroy
>>>
>>> As you might guess, 1 person has n photos, and each photo has a url 
>>> property. I am trying to remove any photos with "amazon" in the URL.
>>>
>>> When I do this, I get the following:
>>>
>>> NoMethodError: undefined method `gsub' for 
>>> #<Addressable::URI:0x3fc672305d40 URI:amazon>
>>>
>>> Any insight into solving this is appreciated.
>>>
>>> Thanks.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/K0BzmeduifoJ.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to