User.find_each |user|
user.update_attributes(status: 'active')
end
But that takes a long to complete. Executing raw sql over ActiveRecord speeds things up tremendously.
User.connection.execute("update users set status = 'active'")
User.find_each |user|
user.update_attributes(status: 'active')
end
But that takes a long to complete. Executing raw sql over ActiveRecord speeds things up tremendously.
User.connection.execute("update users set status = 'active'")
group :development, :test do
gem 'rspec-rails'
end
heroku db:pull
However that gets real slow real quick so I had to use PG Backups addon instead
# Install heroku addon
heroku addons:add pgbackups
# Capture latest db snapshot on heroku
heroku pgbackups:capture
# Get download url and enter it in browser with a heroku login session
heroku pgbackups:url {latest_backup_name}
# Restore pg dump into local PostgreSQL database
pg_restore -d {db_name} ~/Downloads/{latest_backup_name}.dump
# This always return a big fat zero
number_to_percentage(User.count/Signup.count)
# Remember to have divide by floats!
number_to_percentage(User.count.to_f/Signup.count.to_f)