Skip to content

Instantly share code, notes, and snippets.

@diegonarducci
diegonarducci / rails_setup.md
Created September 29, 2021 03:28 — forked from ryanflach/rails_setup.md
Common setup for a new Rails project
  1. rails new <project_name> -d postgresql --skip-turbolinks --skip-spring -T
  • -d postgresql sets up the project to use PostgreSQL
  • --skip-turbolinks & --skip-spring creates a project that does not use turbolinks or spring
  • -T skips the creation of the test directory and use of Test::Unit
  1. In the Gemfile:
  • Available to all environments:
    • gem 'figaro' - store environment variables securely across your app (docs)
    • Uncomment gem 'bcrypt', '~> 3.1.7' if you will be hosting your own user accounts with passwords (docs)
  • Inside of group :test:
    • gem 'rspec-rails' - user rspec in place of minitest (docs)
@diegonarducci
diegonarducci / fixing_all_sold_units_migrated.rb
Last active December 26, 2018 14:58
Script que vai voltar todas as units já vendidas e ainda não pagas para o vendedor original. usando o outpost_id da UNIT como referencias para saber qual era o vendedor antes de migrar para o usuário [email protected]
# SELLER_ID: 10655653 = [email protected]
# estamos pegando todas as units que precisam ser pagas, que o seller_id é do usuários central
# mas o outpost_id ainda é do usuários antigo, garantido que estamos voltando somente as units
# que foram migradas, mas as que forma vendidos pós migração não.
units = Unit.where(deleted_at: nil).
where(seller_id: 10655653).
where.not(outpost_id: 10655653).
where(state: ['authorized','completed']).
where(blocked: false).