This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the validator | |
# app/validators/array_validator.rb | |
class ArrayValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, values) | |
Array(values).each do |value| | |
options.each do |key, args| | |
validator_options = { attributes: attribute } | |
validator_options.merge!(args) if args.is_a?(Hash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'English' | |
namespace :db do # rubocop:disable Metrics/BlockLength | |
task :prevent_disparate_pg_dump_versions => :environment do | |
allowed_pg_dump_version = '9.6.10'.freeze | |
`pg_dump --version` | |
pg_dump_exit_status = $CHILD_STATUS.exitstatus | |
locally_installed_version = `pg_dump --version`.chomp[/(\d.*)/,1] rescue nil |
This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps.
Further, this particular set up plays nicely with Heroku Review Apps in that the release
phase script will:
- Fail, loudly, if the DB does not yet exist.
- Load the DB schema if the current schema version (as determined by
bin/rails db:version
) is0
. - Run DB migrations otherwise.
For a "normal" app that usually means it will run the DB migrations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :staging do | |
desc 'create subdomain DNS record for Heroku review app' | |
task :publish_dns do | |
require 'dnsimple' | |
require 'platform-api' | |
STAGING_DOMAIN = 'mystagingdomain.com'.freeze | |
DNSIMPLE_ACCOUNT_ID = .freeze | |
heroku_app_name = ENV['HEROKU_APP_NAME'] | |
subdomain = heroku_app_name.match(/.*(pr-\d+)/).captures.first |
No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.
- Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
- Create or import a key -- see below for https://keybase.io
- Run
gpg --list-secret-keys
and look forsec
, use the key ID for the next step - Configure
git
to use GPG -- replace the key with the one fromgpg --list-secret-keys
So you want to generate ISO8601 formatted timestamps in Ruby, but need resolution finer than a second?
First, make sure to require 'time'
in order to get ISO8601 formatting. But that gets you this:
2.1.0 :001 > require 'time'
=> true
2.1.0 :002 > Time.now.utc.iso8601
=> "2015-11-12T04:46:43Z"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionMailer::Base.class_eval do | |
class << self | |
protected | |
# Override the version from the actionmailer gem in order to not log attachments. | |
# | |
# Note: This depends on the patch from https://github.com/mikel/mail/pull/858, which adds | |
# parts.inspect_structure and fixes an issue with mail.without_attachments! | |
# |
NewerOlder