OOZOU
与我们联系
返回 TIL 列表
ruby on rails

不经过 HTTP 把文件附加到 ActiveStorage

October 13, 2020

如果你想附加一个在磁盘上生成的文件,或者从用户提交的 URL 下载下来的文件,可以这样做。

@model.image.attach(
    io: File.open('/path/to/file'),
  filename: 'file.pdf',
  # content type is optional
  content_type: 'application/pdf'
)

更多关于 ruby on rails 的笔记

ruby on railsFebruary 10, 2022

用 Pundit Policy 管理 permitted parameters、默认值与各 action 的参数

要管理 permitted params,你可以在你的 policy 中加入 permitted\attributes 和 permitted\attributes\for\#{action},例如

ruby on railsJanuary 31, 2022

在 Turbo 中用 `requestSubmit` 提交表单

Turbo 会监听 form 上的 submit 事件。因此,用 JS 提交表单时,请一律使用 requestSubmit。

ruby on railsJanuary 19, 2022

在 GitHub Actions 中让 Rubocop 与 ESLint 忽略 bundled gems

Rails 项目在 GitHub actions 中通常会把 gems 安装到 vendor 目录,方便在后续运行时使用缓存。

有项目想法吗?

我们很想听听您正在做的产品。

开始对话hello@oozou.com
OOZOU Logo

曼谷 · 新加坡 · 香港

X
Facebook
Instagram
LinkedIn
OOZOU Co., Ltd.
548 One City Centre
Ploenchit Road
Bangkok 10330
Thailand
+66 2544 0000
hello@oozou.com

服务

  • Web 开发
  • AI 智能体与生成式 AI
  • 移动应用开发
  • 数据分析与工程
  • UI/UX 与产品设计
  • 数字化转型

公司

  • 关于我们
  • 加入我们
  • 博客
  • 案例研究
  • Today I Learned
  • 联系我们

更多

  • 行业
  • 合作伙伴网络
© 2026 OOZOU. 版权所有。
隐私政策行为准则反贿赂反贪腐政策