ruby on rails - Include or extend a class/module from a gem (e.g. devise) -


i have written small module lib/encryption/encryption.rb

module encryption   def self.encrypt(value)     ...   end    def self.decrypt(value)     ...   end end 

i want use/access module in these 2 files devise, namely:

  1. token_authenticatable.rb
  2. authenticatable.rb

i have overwritten both of them creating 2 new files , putting them /config/initilaizers (copied original source code within them , modified them)

  1. /config/initializers/token_authenticable.rb
  2. /config/initializers/authenticatable.rb

one file looks instance:

require 'devise/strategies/token_authenticatable' require './lib/encryption/encryption.rb' #tried this, not work  module devise   module models     # tokenauthenticatable module responsible generating authentication token ,     # validating authenticity of same while signing in.     ... 

my modifications work, how can access lib/encryption.rb module within these files? modification approach best practice? if not, right approach?

if have in application.rb:

config.autoload_paths += %w(#{config.root}/lib) 

then '/lib' autoloaded. meaning can call

require 'encryption/encryption' 

and should work.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -