small medium large xlarge


I had a similar problem. It turned out that i made a typo in store_controller.erb. In the index action, instead of
if params[:set_locale]
I wrote
if params[:locale]
and couldn’t select Espanol.
I’ve had issues with the language box in Safari 5, I can’t select Espanol. the code for that is in: store.html.erg

<%= select_tag 'locale', options_for_select(LANGUAGES, I18n.locale), :onchange => 'this.form.submit()' %>
Anyone knows the answer?
On mine (Rails 2.3.8) I had to add .to_s to I18n.locale as it returns a symbol, not a string.

<%= select_tag 'locale', options_for_select(LANGUAGES, I18n.locale.to_s), :onchange => 'this.form.submit()' %>

Pierre says:

This refers to Playtime Task 2, Activity 2

I have added a helper to application_helper.rb

  def currency_to_locale(price)
    price = price * 1.3 if 'es' == I18n.locale.to_s
    number_to_currency price

Then in app/views/store/index.html.erb I utilize the helper

  currency_to_locale(product.price) %>

And also in app/views/store/_line_item.html.erb

  <td class="item_price"><%= currency_to_locale(line_item.total_price) %></td>

And finally in app/views/carts/_cart.html.erb

  <td class="total_cell"><%= currency_to_locale(cart.total_price) %></td>

This works fine in the browser. But the functional and integration test fails each with the same error

ActionView::Template::Error: undefined method `currency_to_locale' for #<#<Class
    ~/work/depot/app/views/line_items/_line_item.html.erb:9:in `_app_

A solution to the problem can be found here:

You have to add following to test/test_helper.rb

  require './app/helpers/application_helper'
  require ApplicationHelper

Then the test should run without errors

Page History
  • V7: Pierre Sugar [over 5 years ago]
  • V6: Pierre Sugar [over 5 years ago]
  • V5: Pierre Sugar [over 5 years ago]
  • V4: Pierre Sugar [over 5 years ago]
  • V3: Pierre Sugar [over 5 years ago]
  • V2: Boris Maletic [almost 7 years ago]
  • V1: Andrew de Andrade [over 7 years ago]