ECのウェブ担当者のメモ

ECサイトを運営管理している、WEB担当プログラマのメモ

スポンサーリンク

Rails x Vue x Graphql x webpackerの IE11対応

自分用のメモ

f:id:jun9632:20200410163537p:plain

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対応はそろそろ終わりにしたい。

関連記事

marketing-web.hatenablog.com

これからはじめるVue.js実践入門

これからはじめるVue.js実践入門

key must be 32 bytes | ActiveSupport::MessageEncryptor

f:id:jun9632:20200408095434p:plain

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バイトしか使わずに暗号/複合しているっぽい。

関連記事

marketing-web.hatenablog.com

marketing-web.hatenablog.com

undefined method `raise_in_transactional_callbacks=' エラー

f:id:jun9632:20200408093920p:plain

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については下記

railsguides.jp

関連記事

marketing-web.hatenablog.com

marketing-web.hatenablog.com

Rails の Activerecordで is null かつ empty をselect したい時

f:id:jun9632:20200127111026p:plain

RailsActiverecord で 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 = ''")

を書いていましたがだいぶ無駄でした、、、

関連記事

marketing-web.hatenablog.com

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)

以上です

参考サイト

buefy.org

関連記事

marketing-web.hatenablog.com

marketing-web.hatenablog.com

基礎から学ぶ Vue.js

基礎から学ぶ Vue.js

  • 作者:mio
  • 出版社/メーカー: シーアンドアール研究所
  • 発売日: 2018/05/29
  • メディア: 単行本(ソフトカバー)

MacでHeroku cli をインストールする。

mac で heroku-cli をインストールします

$ brew tap heroku/brew && brew install heroku

インストール完了後

$ heroku -v

をして、下記のようにversionが返ってくれば成功です。

heroku/7.35.1 darwin-x64 node-v12.13.0

devcenter.heroku.com

関連記事

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

関連

marketing-web.hatenablog.com

marketing-web.hatenablog.com

Ruby on Rails 6 実践ガイド (impress top gear)

Ruby on Rails 6 実践ガイド (impress top gear)