2020-07-01から1ヶ月間の記事一覧
nodenv-yarn-installというプラグインをnodenvに導入してからnodenvでnodeをインストールすると利用可能になる github.com 導入方法をプラグイン用のフォルダをなければ作成しgitからcloneする READMEの通りだかが以下のコマンドで導入する For Bash, Zsh us…
author="調べたい人のユーザー名" year=2020 month=("01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12") for m in "${month[@]}" do echo "$year-$m\t"$(git log --date=iso --author="$author" --pretty=format:"[%ad] %h %an : %s" | grep "$y…
belongs_to のオプションで :touch を指定する :touchオプションをtrueに設定すると、そのオブジェクトがsaveまたはdestroyされたときに、関連付けられたオブジェクトのupdated_atタイムスタンプやupdated_onタイムスタンプが常に現在の時刻に設定されます。…
コンポーネントのDOMを参照したい場合 this.$refs.myComponent.$el で取得できる qiita.com
今まではtimecop使ってたんだけど、細かい制御までは特にする必要もなかったので ActiveSupport::Testing::TimeHelpers を使ってみる spec/rails_helper.rbに以下を追記 # This file is copied to spec/ when you run 'rails generate rspec:install' requir…
Gemを更新 source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -gem 'rails', '~> 5.2.4.3' +gem 'rails', '~> 6.0.3.2' gem 'pg' gem 'puma' gem 'turbolinks', '~> 5' bundle update rails アップデートタス…
サーバーにsshでつないで下記コマンドを実行すると10GBのファイルが作られる dd if=/dev/zero of=tempfile1 bs=1M count=10000 countのとこの数字を変更して作りたいファイルのサイズは調整する
paramsにドットが入るとデフォルトではRouting Errorが返される resources :users, constraints: {id: /[-a-zA-Z0-9.\-_\+]+/} このように指定すると id にアルファベットとマイナスとドットとアンダーバーとプラスを許容できる railsguides.jp
ログインに利用するキーを変更するには通常 config/initializers/devise.rbの中の # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating a user. The default is # just :email. You can configure i…
saved_changeや(項目名)_previous_changeを使って変更を確認する user = User.new user.email = "test@example.com" user.save p user.email_previous_change ["", "test@example.com"] class User < ApplicationRecord after_save :do_somothing_if_email_c…