Restarting all God tasks
To restart all tasks monitored by
God
Show archive.org snapshot
, don't use god restart
. This command is only meant to soft-restart a given process or group.
Instead you should:
god stop
god terminate
god start -c yourgodconfig.god
Related cards:
Resque + God + Capistrano
Attached is a working config to deploy an application with Capistrano that needs to monitor Resque workers with God.
God will run as the...
Adjust cron jobs to allow full backtraces for rake tasks
As we get an exception notification, when a cron job fails, we wish to have the full backtrace in this mail. A rake task doesn't output the full backtrace by default, so you need the --backtrace
option.
Trigger
You will find fail mails wit...
Custom RSpec matcher for allowed values (or assignable_values)
In contrast to RSpec's included allow_value
matcher, the attached matcher will also work on associations, which makes it ideal for testing assignable_values
.
Usage example
describe Unit do
describe '#building' do
it 'shoul...
How to: Upgrade CarrierWave to 3.x
While upgrading CarrierWave from version 0.11.x to 3.x, we encountered some very nasty fails. Below are the basic changes you need to perform and some behavior you may eventually run into when upgrading your application. This aims to save you some...
PSA: Dont allow private gems to be pushed to rubygems.org
If you make a gem with Bundler, you will get a rake release
task that will instantly publish your gem to rubygems.org for all the world to admire. For private gems this is very bad.
To make sure this cannot happen, rubygems 2.2+ allows you to r...
ActiveRecord: scoped `validates_uniqueness_of` allows one null value per scope
As you most likely know validates_uniqness_of :foreign_id
does not allow nil
values by default.
To allow nil
one has to set the :allow_nil => true
option.
Very unexpected scoping this validation will **not raise an error if foreign_id
...
Apache: Require username/password authentication except from a single IP, host or network
You configured authentication in your Apache configuration that requires username and password but you want a single IP address, host or network to allow access without entering credentials you can use the code below.
To allow a network you can u...
Maintaining custom application tasks in Rails
Here are some hints on best practices to maintain your tasks in larger projects.
Rake Tasks vs. Scripts
- The Rails default is using rake tasks for your application tasks. These live in
lib/tasks/*
. - In case you want to avoid rake for your...
Managing Rails locale files with i18n-tasks
When internationalizing your Rails app, you'll be replacing strings like 'Please enter your name'
with t('.name_prompt')
. You will be adding keys to your config/locales/*.yml
files over and over again. Not to miss any key and place each at t...
Rails: How to list all validations on a model or an attribute
If a model inherits from others or uses many concerns / traits, it might be hard to see in the code which validators it has.
But fortunately there's a method for that:
irb(main):002:0> pp UserGroup.validators
[#<ActiveModel::Validations::...