Skip to content

Instantly share code, notes, and snippets.

@Gaolz
Gaolz / 如何封装公共方法到 Rails Engine 中及其注意事项.md
Last active September 26, 2020 15:38
如何封装公共方法到 Rails Engine 中及其注意事项

1. 什么是 Rails Engine

  • Rails Guides:Engine 可以看作为宿主应用提供附加功能的微型应用(如 feedmob-rescue, feedmob-sidebar)

  • 而 Rails Application 实质上就是一个加强版的 Engine

2. Rails Engine 优缺点

1. 背景:当宿主应用过于复杂且有某一功能耦合度不高时可以单独抽出来做成一个 Engine.

2. 优点:

  • 解耦 (避免宿主应用代码过多,导致难以维护)
  • 可以针对 engine 单独测试
@Gaolz
Gaolz / aec_cipher.rb
Created September 22, 2017 07:15 — forked from axtutuu/aec_cipher.rb
Ruby DES-ECB & PKCS5Padding で暗号化
# 暗号モード: ECB
# パディング方式: PKCS5Padding
# OpenSSL::Cipher.ciphers で利用可能な暗号方式名を取得可能
# https://docs.ruby-lang.org/ja/latest/class/OpenSSL=3a=3aCipher.html
module AesCipher extend self
KEY = "Your key"
CIPHER = "DES-ECB"
def encrypt(text)
@Gaolz
Gaolz / rdrc2016.md
Created July 2, 2016 01:44 — forked from cheeaun/rdrc2016.md
RedDotRubyConf 2016 links & resources 😘
@Gaolz
Gaolz / hello.rb
Created March 19, 2014 10:52
something new
def hello
puts "hello world!"
end