Forum: Ruby on Rails How to delete a set of records

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
811a7ce34dba822b542ca2fe916b913f?d=identicon&s=25 Shaun (Guest)
on 2005-11-22 17:37
I'm trying to delete a set of records from the database using parameters
other than the primary key. Is there a method similar to find_by_sql()
that can be used to issue a delete statement like this. Thanks in
advance.

Shaun
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 technoweenie (Guest)
on 2005-11-22 17:50
(Received via mailing list)
On 11/22/05, Shaun <sszot@mscs.mu.edu> wrote:
> I'm trying to delete a set of records from the database using parameters
> other than the primary key. Is there a method similar to find_by_sql()
> that can be used to issue a delete statement like this. Thanks in
> advance.
>
> Shaun

Foo.destroy_all 'bar < 5'

http://rails.rubyonrails.com/classes/ActiveRecord/...

--
rick
http://techno-weenie.net
811a7ce34dba822b542ca2fe916b913f?d=identicon&s=25 Shaun <sszot@mscs.mu.edu> (Guest)
on 2005-11-22 18:01
technoweenie wrote:
> On 11/22/05, Shaun <sszot@mscs.mu.edu> wrote:
>> I'm trying to delete a set of records from the database using parameters
>> other than the primary key. Is there a method similar to find_by_sql()
>> that can be used to issue a delete statement like this. Thanks in
>> advance.
>>
>> Shaun
>
> Foo.destroy_all 'bar < 5'
>
> http://rails.rubyonrails.com/classes/ActiveRecord/...
>
> --
> rick
> http://techno-weenie.net

Just what I was looking for. Thanks Rick.
This topic is locked and can not be replied to.