Install
Gemfile
gem 'locked', git => '[email protected]:BlueLemon/Lockable.git'
Model
Model < ActiveRecord::Base acts_as_locked(:foo, :bar) end
Migration
class AddLockedToPerson < ActiveRecord::Migration def change add_column :model, :locked_at, :datetime end end
Example of usage
In the Person model add
class Person < ActiveRecord::Base # name:string # age:integer acts_as_locked(:name) end
In rails console
p = Person.new p.name = "Oldani Pablo" p.lock p.save # true p.name = "Eloy Espinaco" p.save # false p = Person.new p.name = "Oldani Pablo" p.lock p.save # true p.age = "30" p.save # true