Skip to content

Instantly share code, notes, and snippets.

@taketo1113
taketo1113 / Replace 'factory_girl' to 'factory_bot'.md
Last active February 4, 2021 03:07
Replace 'factory_girl' to 'factory_bot'

Replace 'factory_girl' to 'factory_bot'

  • edit Gemfile
gem 'factory_bot_rails'
  • gem install
$ bundle install
@taketo1113
taketo1113 / ActiveRecord conditions not containing null or empty.md
Last active October 28, 2017 14:10
How to write an ActiveRecord conditions not containing null or empty

ActiveRecord conditions not containing null or empty

> User.where.not(email: [nil, '']).to_sql
=> "SELECT \"users\".* FROM \"users\" WHERE (NOT ((\"users\".\"email\" = '' OR \"users\".\"email\" IS NULL)))"
  • env
    • ruby: 2.4.1
  • rails: 5.0.2
@taketo1113
taketo1113 / Render with locale for view spec.md
Created May 2, 2017 02:11
Render with locale for view spec
#
# Install jq on Raspberry Pi
#
# jq
# - http://stedolan.github.io/jq/
#
curl -O http://stedolan.github.io/jq/download/source/jq-1.4.tar.gz
tar xfvz jq-1.4.tar.gz
cd jq-1.4