sharoa
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 【第13週】パRails輪読会🚂 \(2023\-11\-13\~ 2023\-11\-17\) ###### tags: `パRails🚂` - [開催概要](https://hackmd.io/4A_8ahJtQNi5hz713N5Y7w?view) - [パRails輪読会 ノートまとめ](https://hackmd.io/jsgA8Pf_RVioOgSL_VOR4g) - サンプルコード・正誤表:[サポートページ:パーフェクトRuby on Rails【増補改訂版】:|技術評論社](https://gihyo.jp/book/2020/978-4-297-11462-6/support) - **サンプルコードをダウンロードしただけでは、すぐに`rails s`できない可能性が高い**です。 以下のページに環境構築の手順をまとめたので、ドライバーをやってくださるという方は、こちらに沿って環境構築をお願いします🙏 ⏩ [環境構築の手順 2022年版](https://hackmd.io/y7qb2BRMT2Wd4tAtKYObcQ) ⏩ [環境構築の手順 2023年版](https://hackmd.io/3_lnn8_QRD6wEjwFbWcBzQ) 💁‍♀️ [更新の手順 2章編](https://hackmd.io/pZAmF2EjSmyQ38lUtJ_CqA) ## 目次 [TOC] ------ ## 2023\-11\-13(月) ### ファシリ ### ドライバー @ayu_0505 ### 読んだところ PR: https://github.com/motohiro-mm/Perfect_Ruby_on_Rails_Ch5/pull/7 ### 次回 ### 学んだこと・感想 ------ ## 2023\-11\-14(火) ### ファシリ @hiromisugie ### ドライバー @moegi29 ### 読んだところ 5-3-4 「Action Mailerのテスト」の項のみ。 PR: https://github.com/motohiro-mm/Perfect_Ruby_on_Rails_Ch5/pull/8 ### 次回 5-4 243p 「Action Mailboxによるメール受信」から。🚂 ### 学んだこと・感想 - @sharoa - 久しぶりのノートな気がするw - Action Mailerのテストとして単体テストが用意されていて、ActionMailer::TestCaseを継承としてテストクラスを作るそう。 - 最初のgenerateの時にすでにテストクラスが生成されている。 - このテスト以外にも他にも色々ある。 - テスト関係苦手で、難しいな、としか言えない。 - @hiromisugie - `Option`+`Shift`+`↓`で現在地の行をコピーしてすぐ下にペーストできる - `assert_emails`は、送信されたメールの数が指定された数と一致することを確認するためのもの。色々な`assert`がある。 - @shodan - `assert_emails`は送信されたメールの数が指定された数と一致することを確認するアサーションメソッド。 - 引数は一つ目がメール数、二つ目がメール送信処理のブロック。 - VSCodeの左にあるgitの機能は便利なんですけどコマンドの勉強にならないので注意しないとな〜と思ながら使い続ける日々です……😵‍💫 - @motohiro-mm - `git pull`できないときの対応難しい…コンフリクトが起きてる?調べておきたいと思います。 - `assert_emails(数字)`:指定した数字の数だけメールが送信されているかをテストしてる - option+shift+↓で指定の行を下にコピペできる!今後使います! - @moegi29 - 何度もドライバーやってるはずなのにいまだに慣れない&エラーがでるとテンパってしまう。Gitの知識を増やしたいです。 - コピーしたい行にカーソル当てる→Alt shift ↓押すと行全体コピーできる - assert_emails(1){email.deliver_now}の()はメール送信する数、メール送信するときの処理のブロック ------ ## 2023\-11\-15(水) ### ファシリ - @motohiro-mm ### ドライバー - @hiromisugie ### 読んだところ 5-4 243p 「Action Mailboxによるメール受信」から 5-4-3 246p 「サンプルプロジェクトの作成」まで。 PR: ### 次回 5-4-4 246p 「Action Mailboxの処理の流れと実装手順」から。🚂 ### 学んだこと・感想 - @sharoa - Action Mailboxはメールを受信した時に処理を行う機能を提供するライブラリ(rails6.0で追加) - 例えば、GitHubではプルリクエストにコメントが追加された時にメールが届くけど、そのメールに返信することでコメントを返すことができる。(へぇぇ〜でした。) - Actiton Mailboxが対応するメールサービスやサーバはいくつかある、けど、本で推してるSendGridは個人では使えない。 - Action Mailboxを利用するためには、Active StorageとActive Jobを利用可能にしておく必要がある。 - さらっと知らない単語を出してくる、ほんと。 - @hiromisugie - Action MAilboxはRails 6.0で追加された。アプリ内でコメントを追加したら自動でメールを配信して、そのメールに返信することでアプリ内のコメントに返信したりもできるらしい。 - SendGridやMailgunなど、複数のメールサービス・メールサーバに対応している。ここは実際に使うシーンで試行錯誤しないとコツを掴めなそう…。 - Action Mailboxは、Active StorageやActive Jobを一緒に使うらしい、これもまだピンと来ていない…。 - rails newする際にエラーを出さない方法をドキュメントでまとめていただいていて大変ありがたいなと思いました🙏 - @moegi29 - ActiveStrageには画像だけでなく受信したメールの保存もできる - MIME マイム (多目的なインターネットのメールの拡張という意味)の略語 - ActionMailboxはingress_passwordからパスワードを自動で読み取り認証を行う。RAILS_INBOUND_EMAIL_PASSWORDという環境変数でも設定できるけど複数人で開発している場合はCredentialsを使ったほうが良さそう。 - @shodan - ActionMailboxはメールサービスと連携してメールの受信を行う。 - メール受信時に、ActionMailbox側の連携のためのURLまでリクエストを送信してもらう必要がある。 - メールサービス側に、そのURLを伝えておく必要がある。そのURLは運用するWebアプリケーションのドメインや使用するメールサービスによって変わりそう。 - メールサービスと連携するためにRailsが使うパスワードは、credentials / 環境変数で設定する。 - @motohiro-mm - ActionMailbox:メールを受信したときに処理を行う機能 - 受信メールの保存にActiveStorage - メールに応じた非同期処理の実行およびメールデータの一定期間後削除にActiveJob - `bin/rails action_mailbox:install`で利用できる - ActionMailboxはingress_passwordからパスワードを自動で読み取って認証する - 以前勉強したモデルのアソシエーションや、credentials、ActiveStorage,ActiveJobが当たり前のように出てきて、復習しないとなと感じました - @ayu-0505 - Action Mailboxはメールの受信機能。外部のメールサービス(Mailgun ,Sendgrid等)と協調して動作する。 - 利用するにはActive Jobによる非同期処理 と Active Storageによるデータ保存機能が必要となる。 - `bin/rails actiion_mailbox:install`により、ApplicationMailboxや、migrateファイルが生成される。(Active Storageを利用していない場合はこのタイミングで利用に必要なmigdateファイルが同時生成される) - 外部からのリクエストを認証するためにcredentialsにパスワードを追記しておく。RAILS_INBOUND_EMAIL_PASSWORDという環境変数を利用してもよい。 ## 2023\-11\-16(木) ### ファシリ @motohiro-mm ### ドライバー @shodan ### 読んだところ 5-4-4 246p 「Action Mailboxの処理の流れと実装手順」から 5-4-5 終わりまで。 PR: https://github.com/motohiro-mm/Perfect_Ruby_on_Rails_Ch5/pull/10 ### 次回 5-4-6 253p 「Action Mailboxのテスト」から。🚂 ### 学んだこと・感想 - @sharoa - メールサービスでメールを受信した時にrailsアプリケーション所定のパスへリクエストが送られる。リクエストを受け付けると   - 1️⃣リクエストの認証を行い、パスワードが正しいものであるかを判別する   - 2️⃣InboundEmailモデルのレコードを作る(InboundEmailはメールの処理状態を管理するためのモデル。)   - 3️⃣上の2と同時にメールデータをActive Storageの経由で保存する   - 4️⃣Active Jobを利用して受信メールに対しのて処理を非同期処理バックエンドのキューに登録する   - 5️⃣メールサービスにレスポンスを返す - 4️⃣でキューに登録されたジョブは受信したメールの情報から判断してどんな処理をするかの振り分けをする。振り分けのルールはApplication Mailbox内でroutingメソッドを利用して記述する。 - 複数の条件にマッチするメールが存在していた場合は、config/routes.rbと同じように一番最初にマッチした処理を実行する。 - Action Mailboxは開発用のWeb UIを用意している。   - 動きが見れたのは良かった。 - @sadanora - 正規表現`//i` - `/i`大文字と小文字を区別しない - 完全に忘れていたので教えていただけてよかったです! - InboundEmail - [Action Mailbox の基礎 \- Railsガイド](https://railsguides.jp/action_mailbox_basics.html#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB) - >受信メールはActive Recordを用いてInboundEmailレコードになり、Active Storageによってライフサイクルトラッキングや元のメールのクラウドストレージ保存を行い、データを「on-by-default incineration(焼却)」で責任を持って扱います。 - Action Mailboxで扱う受信メールは基本的にこのActiveRecord::InboundEmailクラスのオブジェクトとして扱われる...てコト? - @moegi29 - ActiveJobのキューに登録されたジョブは受信したメールの情報から判断してどんな処理をするのか振り分けられる。振り分けの定義はApplicationMailBox内でroutingメソッドを利用する。 - /i は正規表現で大文字と小文字を区別せずにマッチを行うものというのを忘れていた - ActionMailBoxを開発するWEbUIの動きを見れたのがたのしかった - @motohiro-mm - `app/mailboxes/application_mailbox.rb`にメールがどのような処理に移るか書いておく - Mailboxクラスは`rails g mailbox 名前`で生成できる - 実際のメールの処理(`process`とかのところ)は正直なんとなくしか分からなかったので、もう一度読みます - 設定はいまひとつわかっていませんが、実際の画面で受信したメールの一覧等が見られてわかりやすかったです! - @shodan - `InboundEmail`モデルが、メールの処理状態を管理している。 - 受信したメールの情報に応じてルーティングを行い、それに応じた処理を分けることができる。 - ドライバー、慣れておらずタイピングも遅くなり流れが遅くなってすみませんでした〜🙇‍♂️ - @hiromisugie - 受信したメールの内容に応じてどんな処理をするのか振り分けるための定義方法が、routes.rbと少し似た方法というのが、へ〜という感じだった - ActionMailboxの処理の流れについてWeb UIで確認することができた。やはり画面上で実際に動いているのを見ると楽しいし、なんとなく理解も進むような気がする。 - VS Code上でのGit操作、便利そうで気になりました👀 ----- ## 2023\-11\-17(金) ### ファシリ @motohiro-mm ### ドライバー @ayu-0505 ### 読んだところ 5-4-6 253p 「Action Mailboxのテスト」から 5-5-2 256pまで。 PR: ### 次回 5-5-2 257p から。🚂 ### 学んだこと・感想 - @sharoa - Action Mailboxは全体的に難しかったのでまた復習したいと思います。 - Action Textはrails6.0で追加された機能の一つ。 - リッチテキストを編集するためのエディターとリッチテキストを保存するデータベースを簡単に用意してくれるとのこと。   - リッチテキストとは。[Outlookでメール作成時に選べるリッチテキストはどんなときに使う?](https://www.fielding.co.jp/column/Outlook/202012_1/) - Action Textはドラッグアンドドロップによるファイルアップロード機能に対応しており、ファイルアップロードを実現するためActive Storageを利用している。 - 目の前で簡単に画像がアップロードされたのが確認できて良かった。 - @moegi29 - recieve_inbound_email_from_mailメソッドはActionMailbox用のヘルパーメソッド。InboundEmail作成したり、ApplicationMailboxで定義したroutingに対応する処理を実行するもの - InboundEmailには引数として与えられたtoやfromなどが設定されている - リッチテキストはあくまで文字周りの装飾をする。 - ImageMagickのバージョン確認方法は`convert -version`でできる - @sadanora - `receive_inbound_email_from_mail` - ActionMailBox用のヘルパーメソッド - 引数として与えられたtoやfromなどが設定されたInboundEmailを作ってくれる。テストでこのメソッドを使う。 - ActionText - リッチテキストエディタとリッチテキストを保存するDBをかんたんに用意できる機能。 - @motohiro-mm - ActionMailboxのテストでは、`receive_inbound_email_from_mail`メソッドがある - InboundEmailを作成し、かつActionMailboxで定義したroutingに沿って対応する処理を実行する - ActionTextは、Railsにリッチテキスト機能を追加する - `rails action_text:install`で関連ファイルを生成できる - モデルにリッチテキストを属性としてもたせるには`has_rich_text :リッチにしたい属性`とかく - @ayu-0505 - `receive_inbound_email_from_mail`メソッドはAction MailBox用のヘルパーメソッドで、引数として与えられたto,fromなどが設定されたInboundEmailを作成し、routingに対応する処理を実行するらしい。 - Action Mailboxはなかなか再現できずに難しかった。 - Action Textはリッチテキスト機能を追加する。エディターはWYSIWYG。Active Storageを利用している。 - `has_rich_text :モデルの属性名`でリッチテキスト機能を追加できる。 - @hiromisugie - rfc822というのはメールの規格のようなもの?? - Action Textはリッチテキストを導入できる。WordPressでサイトを作るとき、投稿画面でWYSIWIGにするかプレーンテキストにするかみたいな設定をできるのだけど、Railsでもこれでサクッと実装できるということ? - 今日実際にやってみた感じだとサクッとできてとても便利そう! - 以下は手順メモなので読んでいただかなくて大丈夫です🙇‍♂️ - scaffoldでmessageを作成 - action_text:installを実行 - rails db:migrateを実行 - Gemfileの`gem 'image-processing'`をアンコメント - bundle install - ImageMagickをインストール - Messageモデルに`has_rich_text: content`を宣言 - ビューテンプレートでrich_text_areaヘルパーを利用 - ストロングパラメーターの定義を修正 - LEF - シェルティは、かわいい🐶 -----

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully