Agile Web Development with Rails, Edition 4

Agile Web Development with Rails, Edition 4

16 Deployment 15.3 Task I3: Translating Checkout

15.4 Task I4: Add a locale switcher.

Add form for setting and showing the site based on the locale.

Use CSS to position the form.

edit public/stylesheets/depot.css
.locale {
        float:right;
        padding-top: 0.2em
}

When provided, save the locale in the session.

edit app/controllers/store_controller.rb
  def index
    if params[:set_locale]
      redirect_to store_path(:locale => params[:set_locale])
    else
      @products = Product.all
      @cart = find_or_create_cart
    end
  end

Try out the form

get /en
Home
Questions
News
Contact

Orders
Products
Users

Your Pragmatic Catalog

Debug

Debug It!

Professional programmers develop a knack of unerringly zeroing in on the root cause of a bug. They can do that because they've written a lot of buggy code and then gained experience fixing it. This book captures all this experience -- use it, and you'll find you write fewer bugs, and the ones you do write will become easier to hunt down.

$34.95
Ruby

Programming Ruby 1.9

Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you should add Ruby to your toolbox.

$49.50
Wd4d

Web Design for Developers

Web Design for Developers will show you how to make your web-based application look professionally designed. We'll help you learn how to pick the right colors and fonts, avoid costly interface and accessibility mistakes -- your application will really come alive. We'll also walk you through some common Photoshop and CSS techniques and work through a web site redesign, taking a new design from concept all the way to implementation.

$42.95
post /en
You are being redirected.
get http://localhost:3000/es
Inicio
Preguntas
Noticias
Contacto

Orders
Products
Users

Su Catálogo de Pragmatic

Debug

Debug It!

Professional programmers develop a knack of unerringly zeroing in on the root cause of a bug. They can do that because they've written a lot of buggy code and then gained experience fixing it. This book captures all this experience -- use it, and you'll find you write fewer bugs, and the ones you do write will become easier to hunt down.

34,95 $US
Ruby

Programming Ruby 1.9

Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you should add Ruby to your toolbox.

49,50 $US
Wd4d

Web Design for Developers

Web Design for Developers will show you how to make your web-based application look professionally designed. We'll help you learn how to pick the right colors and fonts, avoid costly interface and accessibility mistakes -- your application will really come alive. We'll also walk you through some common Photoshop and CSS techniques and work through a web site redesign, taking a new design from concept all the way to implementation.

42,95 $US
rake test
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from <class:Railtie> at /home/rubys/.rvm/gems/ruby-1.9.3-r28190/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
(in /home/rubys/svn/rails4/Book/util/work-193/depot)
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from <class:Railtie> at /home/rubys/.rvm/gems/ruby-1.9.3-r28190/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
..........
Finished in 0.240085 seconds.
 
10 tests, 31 assertions, 0 failures, 0 errors, 0 skips
 
Test run options: --seed 21516
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from <class:Railtie> at /home/rubys/.rvm/gems/ruby-1.9.3-r28190/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
..............................................
Finished in 1.537105 seconds.
 
46 tests, 76 assertions, 0 failures, 0 errors, 0 skips
 
Test run options: --seed 21154
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from <class:Railtie> at /home/rubys/.rvm/gems/ruby-1.9.3-r28190/gems/will_paginate-3.0.pre/lib/will_paginate/railtie.rb:6)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
...
Finished in 1.083972 seconds.
 
3 tests, 47 assertions, 0 failures, 0 errors, 0 skips
 
Test run options: --seed 8966

16 Deployment 15.3 Task I3: Translating Checkout