Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use rails ActionView::Helpers::NumberHelper in Sinatra?

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.

like image 535
Brice Stacey Avatar asked Dec 08 '25 15:12

Brice Stacey


1 Answers

I found that only adding:

require 'active_support'

...didn't give me all the ActiveSupport methods I was hoping for (in my case, AS' fancy time parsing methods). As such, I went with this:

Gemfile.rb

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

It's in my Gemfile (since I'm using Bundler).

like image 130
mecampbellsoup Avatar answered Dec 11 '25 12:12

mecampbellsoup



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!