如何为 Sinatra 编写扩展而不将其打包为 gem?

发布于 2024-08-31 02:03:41 字数 145 浏览 1 评论 0原文

我想在 sinatra 应用程序中包含 distance_of_time_in_words 方法,

我不想打包和分发 gem,而这正是 Sintra 文档指示您要做的事情。我只是希望在我看来该方法可以访问。

做到这一点最简单的方法是什么?谢谢。

I want to include the distance_of_time_in_words method in a sinatra app

I don't want to package and distribute a gem, which is what the Sintra docs direct you to do. I just want that method accessible in my view.

What's the easiest way to do this? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ˇ宁静的妩媚 2024-09-07 02:03:41

http://www.sinatrarb.com/intro.html 上查看 Helpers 部分并定义用于路由处理程序和模板的辅助方法

On http://www.sinatrarb.com/intro.html look at Helpers section and define helper methods for use in route handlers and templates

只是偏爱你 2024-09-07 02:03:41

只需将该文件放置在 ruby​​ 加载路径 ($LOAD_PATH) 中的某个位置并需要它即可。或者将代码直接放入您的应用程序文件中。

Just place the file somewhere in your ruby load path ($LOAD_PATH) and require it. Or place the code directly in your app file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文