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
    # 【第15週】パRails輪読会🚂 \(2023\-11\-29\~ 2023\-12\-01\) ###### 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\-29(水) ### ファシリ @hiromisugie ### ドライバー @ayu-0505 ### 読んだところ 5-6-1 265p サーバサイドのコードを実装する から 5-6-1 終わりまで。 PR:https://github.com/motohiro-mm/Perfect_Ruby_on_Rails_Ch5/pull/14 ### 次回 5-6-2 「チャットを完成させる」から。🚂 ### 学んだこと・感想 - @sharoa - 久しぶりだったので、これってなんだっけ?みたいな思いがありました。 - ブロードキャストは接続している全購読者への送信という意味? - まだチャットアプリが途中なのでなんとなくふわっとしていますが、完成した時にはスッキリになるのかそれも不明。 - 自分自身もだけど、タイポはよくしてしまうのであらためて気をつけないとだなと思った。 - @hiromisugie - チャットアプリを作るために、サーバサイドとクライアントサイドそれぞれの設定をしていく必要がある。 - サーバサイドでは`subscribed`メソッド、`speakメソッド - クライアントサイドでは`recieved`メソッド、`speak`メソッド - `speak`メソッドってのが同じ名前だけど、関連性とか処理の流れとかまだ整理できていない…。 - 最終的にalertで正しく表示ができて良かったです😄 - @moegi29 - ひさしぶりだったのでチャネル、購読とは、、となりました。チャネルはWebSocket処理におけるコントローラのような役割を果たしていて、クライアントはWebSocket通信を通じてチャネルと関連付けされる。この関連のことが購読。 - クライアント側で表示されたメッセージを確認できて良かった、時間内で原因が分かってすっきりしました。 - @sadanora - actioncableはサーバサイドは`app/channels/`, クライアントサイドは`app/javascript/channels/`配下に処理を書く。 - 実行順 1. (クライアント側)クライアントサイドでspeakメソッドを呼び出すことでサーバーサイドにメッセージが送信される 2. (サーバー側)サーバサイドで1のメッセージがブロードキャストされ、クライアントに送信される 3. (クライアント側)2のメッセージを受信してreceivedメソッドによってメッセージが表示される - @ayu-0505 - 落ち着いて入力しようと思いました😂>タイポ - サーバーは`app/channels/xxx_channel.rb`、クライアントは`app/javascript/channels/xxx_channel.js`JSファイルで連動している。 ----- ## 2023\-11\-30(木) ### ファシリ @motohiro-mm ### ドライバー @moegi ### 読んだところ 5-6-2 「チャットを完成させる」から 5-6-3 271p 途中まで。 PR: ### 次回 5-6-3 271p Action Cableへの接続先を変更する から。🚂 ### 学んだこと・感想 - @sharoa - 今日でチャットアプリが完成した! - 目の前でチャットができることが確認できて、おお!と感動しました🤩 - ただ、途中の送受信処理の追加や、サーバーサイドの処理の変更など、内容が濃すぎてちょっとおいつけていません。。。。 - なので、またタイミングをみて復習をしたいと思います。 - アダプタを設定したり、またスタンドアローンという構成?環境?というものがあるのも初めて知りました。きちんと覚えておきたいと思います。 - @moegi - チャットアプリ完成、ちゃんと動いてよかった! - やっとクライアントサイド(rb)とサーバサイド(js)を実装するということの認識ができた気がします - 本番で使うには更にアダプタの設定が必要、production環境ではredis,development環境ではasyncアダプタを使う - @motohiro-mm - テキスト入力部分をviewに追加 - `data-behavior="識別子"`を書いておく - クライアントサイドで送受信処理を追加(app/javascript/channels/room_channels.js) - `connected`メソッド:チャットのメッセージを入力した際に発火するイベントを登録 - `querySelector('input[data-behavior="識別子"]')`とすることで、viewに入力されたメッセージと関連づく - `recieved`メソッド:メッセージをうけとりDOMを操作して受け取ったメッセージをHTML上に追加 - サーバーサイドを実装 - メッセージをデータベースに保存 - ActionCableを本番運用するにあたっての設定がいくつかある - アダプタの設定 - デフォルトでは、production環境:redis、development環境:async - サーバーを分ける設定 - デフォルトではWebSocket用サーバとWeb用サーバは同じだが、production環境では分けた方が便利 - WebSocket用サーバをWeb用と分離して動かす状態をスタンドアローンという - @ayu-0505 - 実際に動く状態でチャットルームを完成させることができたのはとても嬉しかった。 - DBへの保存、表示が入力後すぐにできるのはJSとRialsの連携の成せる技なのでしょうか。 - どういう経路でデータが渡っていったのかまだ完全に把握できてはいないので、復習は必要と感じた。 - サーバーをWeb用とWebSocket用に分離してスタンドアローン構成にする、という考え方。 - @sadanora - チャットアプリ完成した🙌 - フロントの入力を受け取って、サーバーがそれを処理してまたクライアントに配信して、という大体の流れの雰囲気はわかった気はするけど、難しい... - アダプタの設定は`config/cable.yml`に書く - デフォルトでも環境ごとの接続先は異なっていて、developmentはasync、productionはredisとなっている - インメモリとかプロセスとかredisとか、よくわからん言葉がめっちゃ出てきてwakaranwakaran - ActionCable用(Websocket)のサーバーとWeb用のサーバーのプロセスは分けたほうが便利なことも多いので、それぞれ分離して動かす工夫が必要って話なのかなと理解した。 - @shodan - 昨日お休みしたので正直なところ?状態の45分でした🤧このあと読み直しておきます。 - `this.perform`の意味がわからなくて5.49の`speak`メソッドの読み方がわからなかったんですがそれも昨日のp266で説明されてました。 - productionでチャット用の(WebSocket用)のサーバーをWeb用と分けるのがなぜ便利?(なんとなく分けたほうがいいのはイメージつくのですが) - 来週から水曜日はお休みします🙏(チーム開発MTGのお昼の方に登録したので) ----- ## 2023\-12\-01(金) ### ファシリ  @motohiro-mm ### ドライバー @shodan ### 読んだところ 5-6-3 271p Action Cableへの接続先を変更する から 5章の最後まで。 PR: ### 次回 6章 Railsアプリケーション開発 から。🚂 ### 学んだこと・感想 - @sharoa - 今日も難しかったです。 - ところどころ出てくるわからん単語を改めてちゃんと意味を調べて、もう一度読み直してみたいと思いました。 - 今思ったことですが、ワーカスレッドってワーカースレッドのこと? - 当たり前ですがテストがきちんと通ったのは良かったです、 - テスト書くのが大の苦手なので、本に書かれているのでも、ウッとなりがちです。が、慣れたいので頑張るw - 難しい難しい言いながらいつの間にか5章が終わって、次回は6章。また気合を入れないとです。 - @hiromisugie - Action Cable全般、全然ピンと来ていない…😅 追いかけると果てしなそうなので、今は頭にインデックスを作る作戦で先に進もうと思います。 - テストを走らせて通ることと、敢えて通らないようにすることも試せてよかったです。 - RubyMineが便利そう! - 6章をちょっと楽しみにしておりました。また超難しいかもですが…。 - @moegi - ActionCableへの接続先変更、接続可能なオリジン設定、認証処理の実装方法の流れを見れた。けど、productionとdevelopmentとか環境の違いによる細かい設定方法はいまいち分かってない - ユーザーを追加して頂いてユニットテストを実際に動かして成功した場合と失敗した場合の動きがみれてよかった - @sadanora - サーバープロセス、ワーカースレッド、URIスキーマとか、よくわからないので調べたい。 - プロセスについては、るびまにちょっと解説記事があった - [『なるほどUnixプロセス』を読む前にちょっとだけナルホドとなる記事](https://magazine.rubyist.net/articles/0060/0060-NaruhodoUnixTip.html) - Railsガイドならこの辺? - [Rails のスレッドとコード実行 \- Railsガイド](https://railsguides.jp/threading_and_code_execution.html) - この辺はUNIXの勉強になるんだろうか? - 正規表現もしれっと出てきていたけど、改めて正規表現の説明とかない感じがパRailsっぽいなと思った。 - RubyMine便利そう!自分のVSCodeも拡張とか入れて色々試したいなーと思いました。 - @shodan - `ActionCable::Connection::Base`というクラスが`identified_by`というWebSocketに接続したユーザーを扱える?メソッドや、接続を取りやめる`reject_unauthorized_connection`メソッド持っており、これらを使いながら認証機能をつくれるらしい。 - ActitonCable用のアサーションメソッドがある(`assert_subscription`とか)。 - 次からはようやく普通の(?)アプリ制作のハンズオンになるみたい?でそれはそれで楽しみです。 - @motohiro-mm - ActionCableの接続先の変更と、接続可能なオリジンの設定、の違いはいまいちわかっていません - 認証処理の実装はなんとなぁくイメージふわっと、という感じ - `identified_by` - ワーカ数の設定:ワーカ数、プロセス、スレッド、がいまいちわかっていない… - 5章をなんとか終わって良かった…のか?という気持ち - @ayu-0505 - ActionCableの接続先変更部分はちょっと難しかったです。タグを見て接続先を判定しているということはHTTP全体(ヘッダー等)の知識が必要なのかもしれません。 - 認証機能も何となくの理解でした。ConnectionクラスのConnectionインスタンスにユーザー情報含め、色々情報が保持されており、それで接続切断等ができるらしいです。 - ワーカー数、スレッド、pool等、検索してみたのですが、ちょっとまだ頭に入ってきませんでした😅もう少し学習が必要な分野だなと思いました。 - テスト確認ありがとうございました。 -----

    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