Forum: Ruby on Rails issuing raw SQL in Rails

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.
Doug L. (Guest)
on 2006-03-09 12:01
Hi -- I have a need to run the following SQL in a test:

"DELETE FROM agents_bookings"

Does anyone know of a way that I can just execute this?
It is to clear a many-to-many relationship in the teardown function of a
test.
Cheers,
   doug.
Dan S. (Guest)
on 2006-03-09 13:43
(Received via mailing list)
Havbe a shot at:

ActiveRecord::Base.connection.execute("DELETE FROM agents_bookings")

HTH,

Dan S.
www.peoplehub.com.au
Doug L. (Guest)
on 2006-03-09 13:56
Dan S. wrote:
> Havbe a shot at:
>
> ActiveRecord::Base.connection.execute("DELETE FROM agents_bookings")
>
> HTH,
>
> Dan S.
> www.peoplehub.com.au

That's perfect, cheers!
Works a treat!
Thanks,
   doug.
This topic is locked and can not be replied to.