スマホにおけるルート証明書について
役割
例: 社内システムで自社端末のみルート証明書を登録しておくことで、社内のサーバにアクセスできる端末を限定可能。
Sequel ProでMySQLにログインできない
Sequel ProからローカルのMySQLに接続しようとしたところ次のエラーが発生。。

MySQLの認証プラグインcaching_sha2_passwordにSqquel Proが対応していないことが問題みたい。
ということでMySQLの設定を弄る。
mysql -u root mysql> select host, user, plugin from mysql.user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | | localhost | root | caching_sha2_password | +-----------+------------------+-----------------------+ mysql> ALTER USER 'root'@"localhost" IDENTIFIED WITH mysql_native_password BY ''; ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 51, found 49. Created with MySQL 80012, now running 80015. Please use mysql_upgrade to fix this error.
ここでまたもや問題発生。
mysql_upgradeを実行しろとのこと。
mysql_upgrade -u root ~~~~ 省略 ~~~~ taskleaf_development.tasks OK taskleaf_development.users OK Upgrade process completed successfully. Checking if update is needed.
気を取り直して再度実行。
mysql> ALTER USER 'root'@"localhost" IDENTIFIED WITH mysql_native_password BY ''; Query OK, 0 rows affected (0.01 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> select host, user, plugin from mysql.user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | | localhost | root | mysql_native_password | +-----------+------------------+-----------------------+
その後、Sequel ProからMySQLに問題なく接続できた。 めでたしめでたし。
参考文献
Formで自動挿入されるエラー出力タグ<div class="field-with-errors"></div>をどうにかしたい
Railsはフォームでバリデーションエラーが発生すると、
自動でタグをを出力するんだけど、結果的にフォームのレイアウトが崩れてしまう。
これを防ぐには次のコードをconfig/application.rbに追加すれば良い。
config.action_view.field_error_proc = Proc.new do |html_tag, instance|
%Q(#{html_tag}).html_safe
end
上記は、divタグの挿入自体を向こうにする為のもの。 他にもいろいろカスタマイズできるらしい。
参考文献
I18nをファイル分割して管理する
アプリケーションをI18n対応する際、1つのyamlファイル(ja.yml)に内容を追加していくと管理が大変になるので、 ファイル分割する方法について調べてみた。
複数のロケールファイルを読み込むには次のコードをconfig/application.rbに追加すれば良い。
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
追加後のapplication.rbがこちら
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Media
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.i18n.default_locale = :ja
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end
end
これでいつも通りI18n.t('hoge.foo.bar')でI18nが使えます。