Example usage:
old_accounts = Account.where("created_at < ?", 1.month.ago)
old_abandoned_trials = AbandonedTrialQuery.new(old_accounts)
old_abandoned_trials.find_each do |account|
account.send_offer_for_support
RSpec.configure do |config| | |
# If you're not using ActiveRecord, or you'd prefer not to run each of your | |
# examples within a transaction, remove the following line or assign false | |
# instead of true. | |
config.use_transactional_fixtures = false | |
config.before :suite do | |
DatabaseCleaner.clean_with :truncation | |
end |
MASTER=`git log --pretty=format:'%H' master | sort` | |
DEV=`git log --pretty=format:'%H' development | sort` | |
for i in `diff <(echo "${MASTER}") <(echo "${DEV}") | grep '^>' | sed 's/^> //'`; | |
do | |
git --no-pager log -1 --oneline $i; | |
done |
# This Rack middleware helps solving the issue with some Rails versions which do not accept | |
# a '*/*;q=0.6' and their variants 'Accept' request header. This header is particularly used | |
# by Google Bot, and if Rails doesn't like it, it will return a 500 or 406 error to Google Bot, | |
# which is not the best way to get your pages indexed. | |
# | |
# References: | |
# - http://stackoverflow.com/questions/8881756/googlebot-receiving-missing-template-error-for-an-existing-template | |
# - https://github.com/rails/rails/issues/4127 | |
# | |
class GoogleBotAware |
def stubbed_sign_in user | |
request.env['warden'].stub :authenticate! => user | |
controller.stub :current_user => user | |
end |
# config/deploy.rb | |
namespace :upstart do | |
desc 'Generate and upload Upstard configs for daemons needed by the app' | |
task :update_configs, except: {no_release: true} do | |
upstart_config_files = File.expand_path('../upstart/*.conf.erb', __FILE__) | |
upstart_root = '/etc/init' | |
Dir[upstart_config_files].each do |upstart_config_file| | |
config = ERB.new(IO.read(upstart_config_file)).result(binding) |
Because loading gems can take longer than you think
$ curl -fsSL https://gist.github.com/jherdman/5025684/raw/a3ccd4b5308723245706b4ae315845fe951b4473/benchmark.rb | ruby
............................................................[DONE]
Gem Time(sec) Pct %
--------------------------------------------------
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.