Skip to content

Instantly share code, notes, and snippets.

@ivanyv
ivanyv / application.rb
Created June 29, 2011 21:12
Exclusively cache Rails GET requests on nginx
config.action_controller.page_cache_directory = Rails.root.join('public', 'cache-GET')
@ivanyv
ivanyv / Rakefile
Created June 13, 2011 16:39
Painfully specify Rails migration versions for rake db:migrate
# Put this inside Rakefile
if ENV['VERSION'].present? && ENV['VERSION'].to_i.to_s != ENV['VERSION']
pattern = '*' + ENV['VERSION'].split(//).map { |l| "#{l}*" }.join
migrations = Dir[File.join(Rails.root, 'db', 'migrate', pattern)]
if migrations.size == 0
puts "No migrations matching `#{ENV['VERSION']}` found."
exit
else
migration = File.basename(migrations.first)
if migrations.size > 1