OOZOU
與我們聯繫
Back to TILToday I Learned

ruby on rails

22 notes on ruby on rails from the OOZOU team.

all topicsshell 30ruby on rails 22ruby 12macos 10vim 7figma 4cli 3javascript 3heroku 1elixir 1
ruby on railsFebruary 10, 2022

Use Pundit Policies to manage permitted parameters, defaults and per action

To manage permitted params you can add permitted\attributes and permitted\attributes\for\#{action} in your policies e.g.

ruby on railsJanuary 31, 2022

Use `requestSubmit` for form submits with Turbo

Turbo listens to submit events on form.  Hence, always use requestSubmit to submit  a form using JS.

ruby on railsJanuary 19, 2022

Ignore bundled gems for Rubocop and ESLint in GitHub Actions

Rails projects will often install gems into the vendor directory in GitHub actions so we can cache them for the consecutive runs.

ruby on railsApril 18, 2021

Rails 6, Ruby 3, Bootstrap 5 and Hotwire

Extending the blogpost from Bootrails with Hotwire: All the fancy new things (as of when I'm writing this TIL):

ruby on railsOctober 27, 2020

Rails Cache-Control

For enabling setting cache-control headers of static assets and using a CDN on Heroku:

ruby on railsOctober 14, 2020

Fix input on Heroku's rails console

If you end up pasting lots of lines into a rails console on Heroku (or else where), you might get issues with the lines "bleeding" into each other.

ruby on railsOctober 14, 2020

Unique ID for DOM in Rails

Rails has many great view helpers, one of which is dom\id:*

ruby on railsOctober 13, 2020

Add new types to Rails 5 attributes API

The Rails 5 attributes API allows us to build form objects very easily.

ruby on railsOctober 13, 2020

Attaching file to ActiveStorage without HTTP

If you want to attach a file you generated on disk or downloaded from a user-submitted URL, you can do it like this.

ruby on railsOctober 13, 2020

Create a Hash from an Enumerable (Rails 6.0)

New method allowing you to create a Hash from an Enumerable:

ruby on railsOctober 13, 2020

Create idempotent migrations

When you want to write destructive migrations please use if\exists: true when you’re trying to remove a table and check for a table existence when you want to add or remove a column…

ruby on railsOctober 13, 2020

How to find god objects in your project (Rails)

Go to your project root and cd into app/models (using CLI obviously) then run wc -lw \ | sort -u*

ruby on railsOctober 13, 2020

HTML forms that submit to another action

I've known for a long time that you can submit values with submit buttons so you can track which button was used to submit the form e.g.

ruby on railsOctober 13, 2020

If you want to override previously set order

If you want to override previously set order (even through default\_scope), use reorder() instead.

ruby on railsOctober 13, 2020

Limited has_many associations

Limited has_many associations

ruby on railsOctober 13, 2020

List your model names

NOTE: RUBYOPT=-W0 avoids verbosity when running rails command which suppresses warnnings.

ruby on railsOctober 13, 2020

Postgres Functions & Non-sargable Queries

Using postgres functions inside a where clause can make a query non-sargable.

ruby on railsOctober 13, 2020

PostgreSQL UPDATE Join

This query shows how to use the PostgreSQL UPDATE join syntax to update data in a table based on values in another table. for example;

ruby on railsOctober 13, 2020

Scope or scope in Rails

scope :human, -> { user.or(author) } scope :terminator, -> { admin.or(robot) } `

ruby on railsOctober 13, 2020

Show TODO and other notes in your Rails app

Did you know you can show all TODOs/OPTIMIZE/FIXME in your rails app with rails notes?

ruby on railsOctober 13, 2020

Tag rails logs with useful information

Just learned about tagged logging in rails. Did you know you can tag a log by using

ruby on railsOctober 13, 2020

Use minItems/maxItems in collection JSON schemas

To make your collection JSON schemas more reilable use minItems and maxItems so that you can trust your API.

有專案構想嗎?

我們很樂意聆聽您正在打造的產品。

開始對話hello@oozou.com
OOZOU Logo

曼谷 · 新加坡 · 香港

X
Facebook
Instagram
LinkedIn

服務

  • Web 開發
  • AI 與生成式 AI 解決方案
  • 行動應用程式開發
  • 資料分析與工程
  • UI/UX 設計與產品設計
  • 數位轉型

公司

  • 關於我們
  • 職涯
  • 部落格
  • 白皮書
  • 案例研究
  • Today I Learned
  • 聯繫我們

更多

  • 產業
  • 索取報價
  • 合作夥伴網絡
© 2026 OOZOU. 版權所有。
隱私政策行為準則反賄賂反貪腐政策