- RubyHack 2019 - The Circle of Lifecycle Events by Nelson Wittwer
- 7 Patterns to Refactor Fat ActiveRecord Models
- We can optionnally use cgriego/active_attr
- ActiveModel::Attributes が最高すぎるんだよな。 - Qiita
require 'openssl' | |
class String | |
def encrypt(key) | |
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt | |
cipher.key = Digest::SHA1.hexdigest key | |
s = cipher.update(self) + cipher.final | |
s.unpack('H*')[0].upcase | |
end |
<?xml version="1.0"?> | |
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> | |
<Configure id="Server" class="org.eclipse.jetty.server.Server"> | |
<!-- only the relevant addition is listed here --> | |
<Call name="addBean"> | |
<Arg> | |
<New class="org.eclipse.jetty.security.HashLoginService"> | |
<Set name="name">MySolrRealm</Set> | |
<Set name="config"> |
class APIController < ApplicationController | |
include JSONErrors | |
# ... | |
end |
require 'cgi' | |
require 'json' | |
require 'active_support' | |
def verify_and_decrypt_session_cookie(cookie, secret_key_base) | |
cookie = CGI::unescape(cookie) | |
salt = 'encrypted cookie' | |
signed_salt = 'signed encrypted cookie' | |
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000) | |
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len] |
You certainly won't need anything installed other than Docker to create Ruby apps...
The idea is to mount the current folder into a temporary Ruby container using the official Ruby image from Docker Hub, then install Rails inside this temporary container, and then create the project skeleton using the rails new
command.
# Start bash inside a Ruby container:
initialize
: once, when the controller is first instantiatedconnect
: anytime the controller is connected to the DOM