Issuing raw SQL in Rails


#1

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.


#2

Havbe a shot at:

ActiveRecord::Base.connection.execute(“DELETE FROM agents_bookings”)

HTH,

Dan S.
www.peoplehub.com.au


#3

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.