ActiveRecord: execute sql
UPDATE wechat_official_accounts
SET unionid = users.unionid
FROM users WHERE wechat_official_accounts.user_id = users.id;
UPDATE wechat_official_accounts
SET unionid = users.unionid
FROM wechat_official_accounts as accounts
INNER JOIN users
ON accounts.user_id = users.id;
ActiveRecord::Base.connection.execute(sql)

Reference

SELECT users.* FROM users
INNER JOIN cvs ON cvs.user_id = users.id
LEFT OUTER JOIN edus ON edus.cv_id = cvs.id