3

I want to use the Rails ActionView::Helpers::NumberHelper module in my Sinatra views. Specifically, I'd like to use number_to_currency though I would love to have additional Rails helpers.

If there is a more appropriate gem for Sinatra that provides number to currency, that would work too. For example, I've looked through sinatra-more, but it doesn't handle currency.

PS. I'm using Bundler.

4

2 回答 2

3

我发现只添加:

require 'active_support'

...没有给我所有我希望的 ActiveSupport 方法(在我的例子中,AS 的花哨时间解析方法)。因此,我选择了这个:

宝石文件.rb

gem 'activesupport', require: 'active_support/all'

它在我的 Gemfile 中(因为我使用的是 Bundler)。

于 2013-12-03T20:17:07.910 回答
2

添加require 'active_support'到您的 sinatra 应用程序的顶部,并将 active_support gem 包含在 bundler gem 列表中。

在 Sinatra 应用程序中包含整个 Active Support 有点违背整个想法,因此您可以查看 Money gem。

require "money"(并将其添加到捆绑器 gem 清单中)。

关于金钱的文档:http: //money.rubyforge.org/

于 2011-02-05T16:28:32.610 回答