Topic: Localized database queries

Hey all,

I've been using the localization gem for multi-language support in my Rails app which seems to work pretty well for flat text.

The next step is to implement localized values for product pricing, i.e. a visitor to the site should be able to select a currency and the app has to display the right values in the product lists.

The prices do not have to be calculated automatically, I have seperate columns in the products table for price_eur and price_usd (just these two for now). Already having a bunch of dependent tables linked to the Product model, I'd prefer this way to putting the price info into another seperate table.

Now my idea was to put a method called price in the Product model which would take currency as an argument and the method would return the relevant price column. Would this be a good way of handling this problem or should I just stick with a relational pricelist table with an id, a currency_name and a price column?

The code would look something like this I suppose:

def price curr
  col = "price_"+curr.to_s

-- jag har ett marsvin