--- title: COSCUP 2020 description: https://coscup.org/2020/ lang: zh-tw dir: ltr breaks: true tags: COSCUP --- {%hackmd BkVfcTxlQ %} --- [TOC] --- ## 玩耍 Ruby 樂高,改組一隻聊天機器人! #### 講者: 吳兆召 #### URL: https://coscup.org/2020/zh-TW/agenda/MRUCX7 LINE Chatbot 回應模式 * 聊天機器人 (自動回覆訊息、Webhook 功能) * 聊天(真人聊天、自動回覆訊息、智慧聊天) 此次分享主要針對 Webhook: * [gem line-bot-api](https://github.com/line/line-bot-sdk-ruby) * 寫一個 POST action * 關掉 Rails 的 CSRF 檢查 ```ruby # controller protect_from_forgery with: :null_session ``` * 在 Line 的後台可設定我們 POST webhook url * 初始化 LINE bot 物件 * 回應方式有兩種: `reply_message` `push_message` * 使用 validate_signature 實現 Signature 認證機制 #### 參考資料: [只要有心,人人都可以做卡米狗-讓 Line Bot 回覆訊息](https://ithelp.ithome.com.tw/articles/10196544) --- ## 使用 Rails Engine 製作開源套件 #### 講者: 郭佳甯 #### URL: https://coscup.org/2020/zh-TW/agenda/YDG9M7 講者簡報: [Google 簡報](https://docs.google.com/presentation/d/1a_KF1d_SN40mGugdFOS74CnhqiuLNfIfcHH77D3rYYs/edit) `rails plugin new rails_egine_test --full` 可在 ruby gem 找得到建立的 gem (此例rails_egine_test) 參考資料: [The ABC of Rails Engines](https://5xruby.tw/posts/rails-engines/) --- ## 我要活下來!Ruby Junior 工程師的存活術 #### 講者: Fred #### URL: https://coscup.org/2020/zh-TW/agenda/QW8PXE #### 參考資料: [Fred hack.md](https://hackmd.io/ZlCZd7DoTCGDjxaI9n1RXQ) 本場投影片:https://www.slideshare.net/FredHung3/ruby-237471664 --- ## 有效結構化你的 Rails 專案 #### 講者: 何澤清 #### URL: https://coscup.org/2020/zh-TW/agenda/WTGAS3 本場投影片:https://speakerdeck.com/tsechingho/you-xiao-jie-gou-hua-ni-de-rails-zhuan-an ##### 至少要活用.. * ActiveHash / ActiveYaml /ActiveJson 當作資料物件 * Query Context 作為跨資料物件查詢的仲介層 * Presenter / Decorator 作為 view 的資料來源 * Form Object 作為表單驗證的把關者 * Service Object 作為串接外部服務的黑盒子 * Operator / FLow Object 作為控制流程的中心物件 ##### 善用 Route 切割業務邏輯 * Admin 和 API 都知道要切成 namespace,為何其他功能不切成 namespace? * 除了切出 namespace ,也能切成 subdomain 做到獨立。 * 既然會掛 rails engine 的 routes 到專案,為何 routes.rb 不切割成數個檔案 ? ##### Rails View 層越簡潔越好 * 多點 Layout 不是壞事,仍照 AMP 只放該頁面需要的 JS、CSS 和資料 * 同個 namespace 的 partial file 不要放到其他 namespace 資料夾 * 改用 Presenter 為主、Decorator 為輔,少用 view helper * 資料要遵守 Single Source of True * 避免多層的 if...else...,盡量只用 if 就好 * 最後大概只剩下 HTML + CSS classnames+ methods + Loops + if 的結構 ##### Namespace 是業務邏輯手段 * 每個業務邏輯都要有自己的 module (namespace) * 流程控制邏輯 / UI 呈現邏輯 / 資料存取邏輯 * Controller / View / Model => web page * Operator / Presenter / Query Context =>page section (components) * 放 app 或 lib 資料夾 * 寫成 rails engine 放專案內,或發佈成 ruby gem ##### Namespace 依類型區分 這種分類方式適合專案不大及初學者使用 * app/contexts * carts/query_context.rb * orders/query_context.rb * app/presenters * carts/popup_presenter.rb * orders/details_presenter.rb * app/forms * carts/update_form.rb * orders/create_form.rb * app/services * payments/create_service.rb * callbacks/update_service.rb ##### Namespace 依需求區分I * app/learning * carts * query_context.rb * update_form.rb * popup_presenter.rb * orders * query_context.rb * update_form.rb * popup_presenter.rb * app/teaching ##### Namespace 依需求區分II * app/components/learning * carts * popup_presenter.rb * app/objets/learning * carts * query_context.rb * update_form.rb ##### React.js + Rails * 不做需要 SEO 的 web page 或 page section 才用 React * 需要 SEO 的頁面用 AMP (in rails view) * React 資料夾切割以頁面為單位 * API 端點依 `需求 namespace` 切割 (例: learning vs teaching) * Presenter -> json.jbuilder -> React component props 程式範疇 -> 架構範疇 Namespace -> Micro servie --- ## 老闆叫我在 Rails App 裡實作 AMP,我該離職嗎? #### 講者: Meng-Ying Tsai #### URL: https://coscup.org/2020/zh-TW/agenda/VSGYP7 本場投影片:http://slides.com/meng-yingtsai/amp-coscup2019 [在你的 Rails App 實作 AMP](https://5xruby.tw/posts/adopt-amp-in-rails/) --- ## 不可能!Service Object 沒有人這樣寫! #### 講者: Cindy #### URL: https://coscup.org/2020/zh-TW/agenda/JMJ3DC 本場投影片:https://hackmd.io/@cindyliu923/Bk8vHlFT8#/ --- ## 你這段 Ruby Code 超速摟,已經沒有人看得懂了! #### 講者: 蒼時弦也 #### URL: https://coscup.org/2020/zh-TW/agenda/TTRCLC 本場投影片:https://speakerdeck.com/elct9620/2020-coscup-ni-zhe-duan-ruby-code-chao-su-lou-yi-jing-mei-you-ren-kan-de-dong-liao DSL: 針對 `特定情境` 所設計的語言,是實現 meta programming 的一種手段 ---
×
Sign in
Email
Password
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