Post concise notes that can be used for quick reference here!

Pessimistic locking in Rails Locking::Pessimistic provides support for row-level locking ruby Account.lock.find(1) Start a transaction and lock at the same time by calli...

  • Updated 2 days ago by vince
Set up CORS on Amazon S3

  • Updated 9 days ago by vince
Use different credit cards for different Heroku apps

  • Updated 14 days ago by vince

bash require 'sidekiq/api' ```yml :verbose: false :concurrency: 15 :max...

  • Updated 22 days ago by vince
Create a random password in Rails

ruby SecureRandom.alphanumeric

  • Updated 24 days ago by vince
Run a Rails server on https and localhost

openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt then rails s -b 'ssl://localhost:3000?key=localhost.key&cert=localhost.crt' This will give y...

  • Updated about 1 month ago by vince
Add Stripe to a Rails app

  • Updated about 2 months ago by vince
Modeling double entry accounting in a relational database https://c...

  • Updated about 2 months ago by vince
Rails Multi Environment Credentials

I ended up deleting master.key and credentials.yml.enc since I'd rather use development and production specific keys and credentials per below ```ruby rails credentials:show --environment=developme...

  • Updated about 2 months ago by vince
Pass persisted params in a Rails form

If the params you want to persist are state and order ruby <% request.params.slice('state', 'order').each do |key, value| %> <%= hidden_field_tag key, value %> <% end %>

  • Updated about 2 months ago by vince
Find a process and kill it in terminal

% ps aux | grep ruby lukeko 29806 0.0 0.0 4277500 696 s000 S+ 6:49PM 0:00.00 <process you don't want> % kill -9 29806

  • Updated about 2 months ago by vince

Go to Only extra things left to do is @import "trix/dist/trix";

  • Updated about 2 months ago by vince
Override update_counters from counter_cache: true

```ruby class Post < ApplicationRecord belongsto :author, countercache: true end class Author < ApplicationRecord has_many :posts def self.updatecounters(id, counters) Author.find(id).dos...

  • Updated 2 months ago by vince
Remove folder and all files inside it in Terminal

using rm can be very dangerous if you're not careful -- get in the habit of using mv instead do this mv .git ~/.Trash instead of rm -rf .git the first command is safer on many levels

  • Updated 2 months ago by vince
Serialized Hash in Rails form

review of what a hash is ```ruby schedule = {mon: true, tue: false, wed: true} schedule[:mon] => true schedule[:tue] => false schedule[:wed] => true schedule[:thu] => nil schedule.class => Hash ```...

  • Updated 2 months ago by vince
Find and kill a process

% ps aux | grep puma 52480 0.0 0.0 4268176 508 s000 R+ 10:10AM 0:00.00 grep puma 52050 0.0 0.8 4517160 142512 s000 T 9:52AM 0:27.34 puma 4.3.5 (tcp://localhost:3000) [crazya...

  • Updated 2 months ago by vince
Use PostgreSQL's interval type as ActiveRecord::Duration

I couldn't bring myself to use an integer as a db column with the amazing interval available. Unfortunately Rails just sees it as a string, but here's how you can get it to work ruby class CreateAv...

  • Updated 2 months ago by vince
Recurring Events in Rails

Create Amazon IAM user

Step 1: Step 2:

  • Updated 3 months ago by vince
SendGrid on Heroku

Not sure why everything I looked online makes it look complicated but this worked. And you don't even need to add the SendGrid gem. /config/environments/production.rb ruby

  • Updated 3 months ago by vince