I think you think about it wrong.
You add this module to the boot path,
but it will only load if you say:
require 'acts_as_lockable'
or
ActsAsLockable
I would advise you to never want to talk about this inside your code.
The correct paradigm you are looking for is the "initializer."
I suggest you create a file called "config / initializers / actions_as_lockable.rb"
In this file you can include all the code,
or just enable require 'acts_as_lockable'
I usually keep these things inside the libs directory
ensure lib is in the boot path
** config / application.rb **
config.autoload_paths += %W(
** lib / actions_as_lockable.rb **
module ActsAsLockable def acts_as_lockable before_create :set_lock include InstanceMethods end module InstanceMethods protected def set_lock now = Time.now.to_s self.lock = Digest::SHA1.hexdigest(now) end end end
then in the initializer
** config / initializers / actions_as_lockable.rb **
require 'acts_as_lockable' ActiveRecord::Base.extend ActsAsLockable
source share