Rails tips¶
Handige commando's¶
Verbind lokaal met je console¶
Gebruiker rol updaten (console)¶
Gebruiker confirmen (via confirmable van Devise) (console)¶
Toegang tot de Rails console (via Cloud66)¶
Locale admin user aanmaken (console)¶
Export Postgres database (in je shell)¶
Import Postgres database (in je shell)¶
Import database (in je shell via rails command)¶
Kill all PostgreSQL connections¶
Filename db.rake:
namespace :db do
desc "Kick out PostgreSQL users from the database."
task kick: [:environment] do
begin
ActiveRecord::Base.connection.execute <<-SQL
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '#{ActiveRecord::Base.connection.current_database}';
SQL
rescue ActiveRecord::StatementInvalid
puts "All connections killed."
end
end
end