Is it possible to lock the database table. MySQL example:
LOCK TABLES users WRITE
.. using some native ActiveRecord methods?
This is not supported by ActiveRecord, you will have to start it manually using
ActiveRecord::Base.connection.execute("LOCK TABLES users WRITE")
You can check out this discussion at ruby-forum.com for more information.
Pass :lock => true to ActiveRecord::Base.find to obtain an exclusive lock on the selected rows Pass :lock => 'some locking clause' to give a database-specific locking clause of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT
For more details see http://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html