OOZOU
お問い合わせ
Back to TIL
ruby on rails

Unique ID for DOM in Rails

2020年10月14日

Rails has many great view helpers, one of which is dom_id:

dom_id(Post.find(12))       <em># => "post_23"</em>
dom_id(Post.new)            <em># => "new_post"
language-rails</em>

You can also provide a prefix:

dom_id(Post.find(23), :edit) <em># => "edit_post_23"</em>
dom_id(Post.new, :custom)    <em># => "custom_post"
language-rails</em>

Official Rails doc

More on ruby on rails

ruby on rails2022年2月10日

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 rails2022年1月31日

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 rails2022年1月19日

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.

プロジェクトをお考えですか?

あなたが構築しているものについてお聞かせください。

会話を始めるhello@oozou.com
OOZOU Logo

バンコク · シンガポール · 香港

X
Facebook
Instagram
LinkedIn

サービス

  • ウェブ開発
  • AI・生成AIソリューション
  • モバイルアプリ開発
  • データ分析・エンジニアリング
  • UI/UXデザイン・プロダクトデザイン
  • デジタルトランスフォーメーション

会社情報

  • 会社概要
  • 採用情報
  • ブログ
  • ホワイトペーパー
  • 事例研究
  • Today I Learned
  • お問い合わせ

その他

  • 業界
  • 見積もりを取得
  • パートナーネットワーク
© 2026 OOZOU. All rights reserved.
プライバシーポリシー行動規範ABACポリシー