Table locking in AttrLocked

As promised, AttrLocked has been updated to include table locking. If you have any tables in your app that you want to be read-only, just put this in your model:

class SomeReadOnlyTable < ActiveRecord::Base
  table_locked
end

That will stop and save/update/delete operations on the model’s table, and you won’t be able to modify the attributes of any instances of it, even new unsaved instances. You can still associate other models with your locked one, as long as the foreign key field itself is not locked in some way.

If you've enjoyed this article, you might enjoy my recently published book JavaScript Testing Recipes. It's full of simple techniques for writing modular, maintainable JavaScript apps in the browser and on the server.