Rails x Vue x Graphql x webpackerの IE11対応
自分用のメモ
Graphql (Apollo) の実行に 下記が必要。 たぶん fetch するため
isomorphic-unfetch
yarn add isomorphic-unfetch
app/javascript/packs/application.js に下記を追加
import "core-js/stable"; import "regenerator-runtime/runtime"; import 'isomorphic-unfetch'
async / await で import "regenerator-runtime/runtime"; が必要らしい
babel.config.js
presets: [ isTestEnv && [ '@babel/preset-env', { targets: { node: 'current' }, useBuiltIns: 'usage', } ], (isProductionEnv || isDevelopmentEnv) && [ '@babel/preset-env', { forceAllTransforms: true, useBuiltIns: 'entry', corejs: 3, modules: false, exclude: ['transform-typeof-symbol'] } ] ]
感想
IE対応はそろそろ終わりにしたい。
関連記事
- 作者:山田 祥寛
- 発売日: 2019/08/22
- メディア: 単行本
key must be 32 bytes | ActiveSupport::MessageEncryptor
Rubyをバージョンアップしたら key must be 32 bytes と怒られました
下記の様な複合化の処理が合った時に、
def self.decrypt(password) secret_key = 'your-key_1234567890123456789012345678901234567890' ActiveSupport::MessageEncryptor.new(secret_key, 'aes-256-cbc') crypt.decrypt_and_verify(password end
32バイトにしないといけないんですね。 上記のように先頭から32バイトで成功します。
def self.decrypt(password) secret_key = 'your-key_1234567890123456789012345678901234567890' ActiveSupport::MessageEncryptor.new(secret_key[0..31], 'aes-256-cbc') crypt.decrypt_and_verify(password end
どうやら、もともと、頭の32バイトしか使わずに暗号/複合しているっぽい。
関連記事
プロを目指す人のためのRuby入門 言語仕様からテスト駆動開発・デバッグ技法まで (Software Design plusシリーズ)
- 作者:伊藤 淳一
- 発売日: 2017/11/25
- メディア: 大型本
undefined method `raise_in_transactional_callbacks=' エラー
Rails のバージョンアップ(5.0 => 6.0)したら、下記のエラーが発生しました。
ERROR NoMethodError: undefined method `raise_in_transactional_callbacks=' for
対処方法
config/application.rb の下記をコメントアウトしたらエラー出なくなりました。
- config.active_record.raise_in_transactional_callbacks = true
↓
+ #config.active_record.raise_in_transactional_callbacks = true
raise_in_transactional_callbacksについては下記
関連記事
Rails の Activerecordで is null かつ empty をselect したい時
Rails の Activerecord で is null かつ empty(空文字)でセレクトした時。
結論は以下です。
User.where(name: [nil, ''])
そうすると
SELECT users.* FROM (users WHERE users.name = '' OR users.name IS NULL)
のようなSQLが発行されます。
最初は
User.where("user.name is null OR users.name = ''")
を書いていましたがだいぶ無駄でした、、、
関連記事
Rails x Vue 環境に Buefyをinstall する
yarn で buefyをinstall
$yarn add buefy
app/javascript/packs/application.js に下記を追加
import Vue from 'vue' import Buefy from 'buefy' import 'buefy/dist/buefy.css' Vue.use(Buefy)
以上です
参考サイト
関連記事
- 作者:mio
- 出版社/メーカー: シーアンドアール研究所
- 発売日: 2018/05/29
- メディア: 単行本(ソフトカバー)
MacでHeroku cli をインストールする。
$ brew tap heroku/brew && brew install heroku
インストール完了後
$ heroku -v
をして、下記のようにversionが返ってくれば成功です。
heroku/7.35.1 darwin-x64 node-v12.13.0
関連記事
ActiveRecoredのmigrationでdrop tableをする
ActiveRecoredのmigrationを使ってdrop tableをする場合のサンプル 一様中身は空になってしまうが、rollbackで戻せるようにしている。
class DropAdminUsers < ActiveRecord::Migration[5.0] def change drop_table :admin_users do |t| t.string :name, null: false t.string :email, null: false, index: true t.timestamps null: false end end end