---
title: "ruby | 今日所學 | OOZOU"
description: "來自 OOZOU 團隊的簡短實用 ruby 筆記。"
canonical: https://oozou.com/zh-Hant/til-topics/ruby
locale: zh-Hant
---

# ruby | 今日所學

> 來自 OOZOU 團隊的簡短實用 ruby 筆記。

- [讓 Pry 支援貼上使用行首點記法的多行 Ruby 區塊](https://oozou.com/zh-Hant/til/allow-pasting-multiline-ruby-blocks-in-pry-when-using-leading-dot-notation-116) ([markdown](https://oozou.com/zh-Hant/til/allow-pasting-multiline-ruby-blocks-in-pry-when-using-leading-dot-notation-116.md)) (2021-04-30): 我們現在很常使用行首點記法，例如
- [不含插值的 Heredoc](https://oozou.com/zh-Hant/til/heredoc-without-interpolation-74) ([markdown](https://oozou.com/zh-Hant/til/heredoc-without-interpolation-74.md)) (2020-10-14): 有時你會想使用 Ruby 的 Heredoc 但不進行插值（'#{....}'）。只要在你的關鍵字前後加上單引號就可以做到：
- [在 Ruby 中自動建立中間層的 Hashtable](https://oozou.com/zh-Hant/til/automagical-intermediate-level-hashtables-in-ruby-62) ([markdown](https://oozou.com/zh-Hant/til/automagical-intermediate-level-hashtables-in-ruby-62.md)) (2020-10-13): 所有中間層的 hashtable 都會自動神奇地建立起來
- [用 rbenv 為單一指令切換 Ruby 版本](https://oozou.com/zh-Hant/til/change-ruby-version-for-single-command-with-rbenv-68) ([markdown](https://oozou.com/zh-Hant/til/change-ruby-version-for-single-command-with-rbenv-68.md)) (2020-10-13): 你可以用 rbenv local 暫時切換 Ruby 版本
- [把 VS Code 的 Go to definition 改成 Cmd+Click](https://oozou.com/zh-Hant/til/change-vs-code-go-to-definition-to-cmd-click-59) ([markdown](https://oozou.com/zh-Hant/til/change-vs-code-go-to-definition-to-cmd-click-59.md)) (2020-10-13): 只要打開你的使用者設定 JSON 檔，使用這個選項：
- [提升 Bundler 效能](https://oozou.com/zh-Hant/til/improve-bundler-performance-56) ([markdown](https://oozou.com/zh-Hant/til/improve-bundler-performance-56.md)) (2020-10-13): 透過在多個 jobs 中同時執行 bundler 任務來提升 bundler 效能：
- [optional relation + RSpec 搭配 shoulda-matchers](https://oozou.com/zh-Hant/til/optional-relation-rspec-w-shoulda-matchers-41) ([markdown](https://oozou.com/zh-Hant/til/optional-relation-rspec-w-shoulda-matchers-41.md)) (2020-10-13): User 1 - 0..1 Laptop
- [移除 ruby 2.6 內建的 bundler](https://oozou.com/zh-Hant/til/remove-ruby-2-6-bundled-bundler-39) ([markdown](https://oozou.com/zh-Hant/til/remove-ruby-2-6-bundled-bundler-39.md)) (2020-10-13): 在已安裝 bundler v2 的情況下用 ruby 2.6+ 產生 rails 6 應用程式，會建立無法使用的 binstubs。如果你看到這個錯誤 You must use Bundler 2 or greater with this lockfile. 你可以移除…
- [對你目前的 branch 執行 rubocop](https://oozou.com/zh-Hant/til/run-rubocop-against-your-current-branch-21) ([markdown](https://oozou.com/zh-Hant/til/run-rubocop-against-your-current-branch-21.md)) (2020-10-13): 對你目前的 branch 執行 rubocop
- [在 commit 之前執行 rubocop](https://oozou.com/zh-Hant/til/run-rubocop-before-commit-8) ([markdown](https://oozou.com/zh-Hant/til/run-rubocop-before-commit-8.md)) (2020-10-13): Git hooks 對於在 Git repository 中自動化任務、落實程式碼規範來說非常強大。Git hooks 的一個常見用途，就是在允許 commit 之前先執行自動化測試和程式碼分析工具…
- [抑制 rspec 警告](https://oozou.com/zh-Hant/til/suppress-rspec-warnings-33) ([markdown](https://oozou.com/zh-Hant/til/suppress-rspec-warnings-33.md)) (2020-10-13): $ RUBYOPT=W0 bundle exec rspec spec/ ...
- [FactoryBot 也可以用在非 ActiveRecord 的 model 上](https://oozou.com/zh-Hant/til/you-can-use-factorybot-for-non-activerecord-models-45) ([markdown](https://oozou.com/zh-Hant/til/you-can-use-factorybot-for-non-activerecord-models-45.md)) (2020-10-13): 你可以用 FactoryBot 的 initialize\with* 方法，以任何你想要的方式初始化物件，讓你能隨心所欲地為任何物件建立 factory

All notes: [今日所學](https://oozou.com/zh-Hant/til) ([markdown](https://oozou.com/zh-Hant/til.md)).

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/zh-Hant/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
