---
title: "ruby | Today I Learned | OOZOU"
description: "โน้ตสั้นใช้ได้จริงเกี่ยวกับ ruby จากทีม OOZOU"
canonical: https://oozou.com/th/til-topics/ruby
locale: th
---

# ruby | Today I Learned

> โน้ตสั้นใช้ได้จริงเกี่ยวกับ ruby จากทีม OOZOU

- [ทำให้วางโค้ด Ruby หลายบรรทัดใน Pry ได้เมื่อใช้ leading dot notation](https://oozou.com/th/til/allow-pasting-multiline-ruby-blocks-in-pry-when-using-leading-dot-notation-116) ([markdown](https://oozou.com/th/til/allow-pasting-multiline-ruby-blocks-in-pry-when-using-leading-dot-notation-116.md)) (2021-04-30): ตอนนี้เราใช้ leading dot notation กันบ่อยมาก เช่น
- [Heredoc แบบไม่มี interpolation](https://oozou.com/th/til/heredoc-without-interpolation-74) ([markdown](https://oozou.com/th/til/heredoc-without-interpolation-74.md)) (2020-10-14): บางครั้งคุณอาจอยากใช้ Heredoc ของ Ruby แบบไม่มี interpolation ('#{....}') ซึ่งทำได้โดยใส่ dash เดี่ยวรอบ keyword:
- [สร้าง hashtable ระดับกลางให้อัตโนมัติใน Ruby](https://oozou.com/th/til/automagical-intermediate-level-hashtables-in-ruby-62) ([markdown](https://oozou.com/th/til/automagical-intermediate-level-hashtables-in-ruby-62.md)) (2020-10-13): hashtable ระดับกลางทั้งหมดจะถูกสร้างขึ้นให้เองโดยอัตโนมัติ
- [เปลี่ยนเวอร์ชัน Ruby สำหรับรันคำสั่งเดียวด้วย rbenv](https://oozou.com/th/til/change-ruby-version-for-single-command-with-rbenv-68) ([markdown](https://oozou.com/th/til/change-ruby-version-for-single-command-with-rbenv-68.md)) (2020-10-13): สลับเวอร์ชัน Ruby ชั่วคราวได้ด้วย rbenv local
- [เปลี่ยน Go to definition ของ VS Code ให้เป็น Cmd+Click](https://oozou.com/th/til/change-vs-code-go-to-definition-to-cmd-click-59) ([markdown](https://oozou.com/th/til/change-vs-code-go-to-definition-to-cmd-click-59.md)) (2020-10-13): แค่เปิดไฟล์ user settings แบบ JSON แล้วใส่ตัวเลือกนี้:
- [เพิ่มประสิทธิภาพ Bundler](https://oozou.com/th/til/improve-bundler-performance-56) ([markdown](https://oozou.com/th/til/improve-bundler-performance-56.md)) (2020-10-13): ให้ bundler ทำงานเร็วขึ้นด้วยการรัน task แบบขนานหลาย jobs:
- [optional relation + RSpec กับ shoulda-matchers](https://oozou.com/th/til/optional-relation-rspec-w-shoulda-matchers-41) ([markdown](https://oozou.com/th/til/optional-relation-rspec-w-shoulda-matchers-41.md)) (2020-10-13): User 1 - 0..1 Laptop
- [ลบ bundler ที่มากับ ruby 2.6](https://oozou.com/th/til/remove-ruby-2-6-bundled-bundler-39) ([markdown](https://oozou.com/th/til/remove-ruby-2-6-bundled-bundler-39.md)) (2020-10-13): การ generate แอป rails 6 ด้วย ruby 2.6+ ในเครื่องที่ติดตั้ง bundler v2 ไว้ จะสร้าง binstub ที่ใช้งานไม่ได้ ถ้าเจอ error You must use Bundler 2 or greater with this lockfile. ให้ลบ…
- [รัน rubocop กับ branch ปัจจุบัน](https://oozou.com/th/til/run-rubocop-against-your-current-branch-21) ([markdown](https://oozou.com/th/til/run-rubocop-against-your-current-branch-21.md)) (2020-10-13): รัน rubocop กับ branch ปัจจุบัน
- [รัน rubocop ก่อน commit](https://oozou.com/th/til/run-rubocop-before-commit-8) ([markdown](https://oozou.com/th/til/run-rubocop-before-commit-8.md)) (2020-10-13): Git hooks มีประโยชน์มากสำหรับงานอัตโนมัติและการบังคับใช้มาตรฐานการเขียนโค้ดใน Git repository หนึ่งใน use case ที่พบบ่อยของ Git hooks คือการรัน test อัตโนมัติและเครื่องมือวิเคราะห์โค้ดก่อน...
- [ปิด warning ของ rspec](https://oozou.com/th/til/suppress-rspec-warnings-33) ([markdown](https://oozou.com/th/til/suppress-rspec-warnings-33.md)) (2020-10-13): $ RUBYOPT=W0 bundle exec rspec spec/ ...
- [คุณใช้ FactoryBot กับ model ที่ไม่ใช่ ActiveRecord ได้](https://oozou.com/th/til/you-can-use-factorybot-for-non-activerecord-models-45) ([markdown](https://oozou.com/th/til/you-can-use-factorybot-for-non-activerecord-models-45.md)) (2020-10-13): ใช้ Method initialize_with ของ FactoryBot เพื่อ initialize object ในแบบที่ต้องการได้ จึงสร้าง factory ให้ object ไหนก็ได้ตามใจ

All notes: [Today I Learned](https://oozou.com/th/til) ([markdown](https://oozou.com/th/til.md)).

---

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

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