* Additional config items in Configuration File You can define your own configuration items in a configuration file (such as the default =~/.arql.yaml= / =~/.arql.d/init.yaml= ), and then get the value of the configuration item in the code with =env_config(/my_env/)["CONF_KEY"]-= . For example, let's say the system encrypts the field of the =account_no= BankAccount table, and you can define the key for encryption in the configuration file: #+begin_src yaml dev: <<: *default host: 127.0.0.1 port: 3306 username: test password: test123456 database: devel encrypt_key: "1234567890abcdef" #+end_src You can then read the value of the config item in the Initialzier code ( =~/.arql.rb= / =~/.arql.d/init.rb= ): #+begin_src ruby class BankAccount def self.encrypt_account_no(account_no) cipher = OpenSSL::Cipher.new('AES-128-ECB') cipher.encrypt cipher.key = env_config(/my_env/)["encrypt_key"] encrypted = cipher.update(account_no) + cipher.final encrypted.unpack('H*').first end def self.decrypt_account_no(encrypted_account_no) cipher = OpenSSL::Cipher.new('AES-128-ECB') cipher.decrypt cipher.key = env_config(/my_env/)["encrypt_key"] decrypted = cipher.update([encrypted_account_no].pack('H*')) + cipher.final decrypted end # 从数据库查询出数据之后,自动解密 account_no 字段 after_find do self.password = decrypt_account_no(self.password) end # 保存数据之前,自动加密 account_no 字段 before_save do self.password = encrypt_account_no(self.password) end end #+end_src You can also use the config method of the Namespace Module to obtain the value of the configuration item, for example: Assuming the Namespace Module is , then =NS= the above code can be rewritten as: #+begin_src ruby class BankAccount def self.encrypt_account_no(account_no) cipher = OpenSSL::Cipher.new('AES-128-ECB') cipher.encrypt cipher.key = NS::config["encrypt_key"] encrypted = cipher.update(account_no) + cipher.final encrypted.unpack('H*').first end def self.decrypt_account_no(encrypted_account_no) cipher = OpenSSL::Cipher.new('AES-128-ECB') cipher.decrypt cipher.key = NS::config["encrypt_key"] decrypted = cipher.update([encrypted_account_no].pack('H*')) + cipher.final decrypted end # 从数据库查询出数据之后,自动解密 account_no 字段 after_find do self.password = decrypt_account_no(self.password) end # 保存数据之前,自动加密 account_no 字段 before_save do self.password = encrypt_account_no(self.password) end end #+end_src