Questions tagged [money-rails]

money-rails provides integration of the money gem with Ruby on Rails.

money-rails provides integration of the money gem with Ruby on Rails.

Both ActiveRecord and Mongoid are now supported.

For more information: https://github.com/RubyMoney/money-rails

86 questions
0
votes
2 answers

Rails rails-money undefined method `cents'

I am attempting to implement money-rails and I have run into the following error: undefined method `cents' for "1,000.00":String I followed this tutorial to get a "fancy" currency input field. DB schema: t.integer "balance_cents", default: 0,…
CChandler81
  • 347
  • 3
  • 14
0
votes
0 answers

How to add money in Ruby

Lets say I have two string: "$7.99" and "$16.99" Now, I'm trying to add these values together to get "$24.98". The money could be in a different currency than USD, but the two strings will always be the same currency. I'm trying to use a combination…
0
votes
1 answer

How to configure decimal_mark and thousand_separator - Money Rails

I'm trying use the gem money-rails but with no success. I live in Brazil and here the decimal mark is "," and the thousand separator is "." So, I add the follow code in a money.rb initializer: MoneyRails.configure do |config| …
0
votes
1 answer

Currency association with money-rails gem

Instead of having a integer _cents field, and a _currency string field, I've created a Currency model, which has: iso_code usd_rate (the exchange rate to USD) name Examples: USD iso_code: "USD" usd_rate: 1 name: "American Dollars" Do you know…
ascherman
  • 1,762
  • 2
  • 20
  • 41
0
votes
1 answer

Using money-rails helper in javascript

Is it possible to use helpers in javascript assets in Ruby on Rails? I'm trying to convert Money object Object { fractional: "21050.0", currency: Object, bank: Object } with avaiable helper humanized_money. In normal view it's working properly <%=…
karlosos
  • 1,034
  • 9
  • 25
0
votes
1 answer

Ruby on rails. Ransack search on money-rails Monetize attribute

I am having problems searching a money-rails/Monetized attribute using ransack. I am only able to search in cents. I have a model (gig) with a money attribute salary. I can create this model no problem with: <%= form.input :salary %> Which saves…
Rob Hughes
  • 876
  • 2
  • 13
  • 32
0
votes
1 answer

How to round price (usd and rupee both )

i want to round price like this 1.5 to 1 and 1.6 to 2 so to do that i added a model and created a method for that in lib folder like this class EuCentralBank < Money::Bank::VariableExchange def calculate_exchange(from, to_currency, rate) …
SreRoR
  • 1,151
  • 1
  • 17
  • 44
0
votes
0 answers

Money-Rails - Simple Form Input

I'm using the money-rails gem for one of my Models to store the cost of manufacture. In my model I have - monetize :cost_of_manufacturing_cents And in the _form.html view I have for simple_form : f.input :cost_of_manufacturing However, when I…
Michael Victor
  • 861
  • 2
  • 18
  • 42
0
votes
1 answer

How to do rounding in moneyrails gem

i want to modify the moneyrails gem like this(in case of USD). if it is above 15.01 it should round to 16) (eg: 15.01 or 15.10 or 15.50 or 15.90 it should exchange to 16) Any help is appreciated
SreRoR
  • 1,151
  • 1
  • 17
  • 44
0
votes
1 answer

Ransack search for price with Money-rails

I'm using Ransack to add a search function to my rails app and I'm also using Money-rails gem to handle price and currency. I want to enter a price in Dollars in the Ransack search field and then it converts it to cents in order to find it in the…
fardin
  • 1,399
  • 4
  • 16
  • 27
0
votes
3 answers

How to convert dollars into cents for money gem

How to convert dollars into cents for money gem There're many currencies type in my database. suppose I have these 3 items in my database amount: 100, currency: NTD amount:100, currency: USD amount:100, currency: JPY Then Money.new(100, :NTD), the…
newBike
  • 14,385
  • 29
  • 109
  • 192
0
votes
2 answers

Validating number field that has capital letters in Ruby

I am trying to validate the entry a user makes in an amount field. The field is amount_money This field is a string which is validated on form submission monetize :amount, :as => :amount_money validates :amount, numericality: {only_integer:…
techguy
  • 47
  • 2
  • 9
0
votes
0 answers

Stop Money gem formatting an input on validation errors

I am using the Money gem with a Rails app. I am rendering the input for the amount using humanized_money. If I enter a wrong format for the amount in the input, besides getting a validation error, the input amount changes to a valid one. My question…
linkyndy
  • 17,038
  • 20
  • 114
  • 194
0
votes
1 answer

Return results from money (ruby) with a comparison (e.g. items more than x)

Pretty simple one. I want to do the following Model.where("money_rate > ?", some_other_money_item) Any ideas? PG::UndefinedColumn: ERROR: column "money_rate" does not exist LINE 1: SELECT "jobs".* FROM "jobs" WHERE (money_rate > '---…
Carpela
  • 2,155
  • 1
  • 24
  • 55
0
votes
1 answer

Money gem converting variable of currency code to lower case

I am using the money gem in rails to perform some currency conversion. I'd like to dynamically set the conversion rate so that I can use it in a script. currency_code = ":SEK" conversion_rate = @bank.get_rate(:USD, currency_code).to_f I get this…
bnussey
  • 1,894
  • 1
  • 19
  • 34