Im integrating a payments gateway, Im using the gem money-rails to handle money in my application, from my controller I have an action to make a charge to the credit card of the user, I would like to use the helpers money-rails has but how it is supposed that you only can use helpers from views then I do not know how to properly get the money amount for sending to the payments gateway, for example, if I have the following money object:
<Money fractional:650 currency:USD>
I would like to get the value 6.5
, for then send it to the gateway, there is a helper for that called: humanized_money
but I can't use it from a controller. Any suggestion would be appreciated.
In Rails 5, view_context
is no longer available.... You can either call your helper method inline in your controller using helpers.humanized_money
or simply call:
ActionController::Base.helpers.humanized_money