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.
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2006-03-09 11: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.
0ca6dacbed829354319d844346cbd5f3?d=identicon&s=25 Dan Sketcher (Guest)
on 2006-03-09 12:43
(Received via mailing list)
Havbe a shot at:

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

HTH,

Dan Sketcher
www.peoplehub.com.au
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2006-03-09 12:56
Dan Sketcher wrote:
> Havbe a shot at:
>
> ActiveRecord::Base.connection.execute("DELETE FROM agents_bookings")
>
> HTH,
>
> Dan Sketcher
> www.peoplehub.com.au

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