I have a product table in my Rails application with following columns:
table "products"
t.string "name"
t.text "description"
t.integer "price"
When I was developing the app, it was just for a single country and for single currency. Now I would like to support more currencies based on geo country but what is the best way to do it with my current database structure?
It was recommended to me to use Money gem but it is just money exchange. What I really want is to set up manually different pricing for different currencies/countries.
Any recommendation on the best way to do it?
Update: We don't plan to have more than like 20 products and our pricing is a bit higher so we don't care about the exchange rate - rather we would like to have different pricing based on how strong is the economy in certain countries
Following up to my comment, I should use the join table prices
between products
and currencies
, with an the has_many :through Association, like shown in documentation.
The join model Price
has columns:
| product_id | currency_id | value |
Price
relations:
class Price < ApplicationRecord
belongs_to :product
belongs_to :currency
end
Of course, the model Currency
is required, which can store, name, country, symbol, flag, ...