Agile Web Development with Rails, Edition 5
16 Deployment
15.3 Task J3: Translating Checkout
15.4 Task J4: Add a locale switcher.
58 (tests|runs), 168 assertions, 0 failures, 0 errors.
<0> expected to be
>=
<1>.
Traceback:
/home/rubys/git/awdwr/edition4/checkdepot.rb:38:in `assert_test_summary'
/home/rubys/git/awdwr/edition4/checkdepot.rb:486:in `block in <class:DepotTest>'
Add form for setting and showing the site based on the locale.
Use CSS to position the form.
edit app/assets/stylesheets/application.css.scss
.locale {
float: right;
margin: -0.25em 0.1em;
}
When provided, save the locale in the session.
edit app/controllers/store_controller.rb
def index
if params[:set_locale]
redirect_to store_url(locale: params[:set_locale])
else
@products = Product.order(:title)
end
end
edit app/views/layouts/application.html.erb
<div id="banner">
<%= form_tag store_path, class: 'locale' do %>
<%= select_tag 'set_locale',
options_for_select(LANGUAGES, I18n.locale.to_s),
onchange: 'this.form.submit()' %>
<%= submit_tag 'submit' %>
<%= javascript_tag "$('.locale input').hide()" %>
<% end %>
<%= image_tag("logo.png") %>
<span class="title"><%= @page_title || t('.title') %></span>
</div>
Try out the form
get /en
Pragmatic Bookshelf
Your Pragmatic Catalog
CoffeeScript
CoffeeScript is JavaScript done right. It provides all of JavaScript's
functionality wrapped in a cleaner, more succinct syntax. In the first
book on this exciting new language, CoffeeScript guru Trevor Burnham
shows you how to hold onto all the power and flexibility of JavaScript
while writing clearer, cleaner, and safer code.
$36.00
Programming Ruby 1.9 & 2.0
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.95
Rails Test Prescriptions
Rails Test Prescriptions is a comprehensive guide to testing
Rails applications, covering Test-Driven Development from both a
theoretical perspective (why to test) and from a practical perspective
(how to test effectively). It covers the core Rails testing tools and
procedures for Rails 2 and Rails 3, and introduces popular add-ons,
including Cucumber, Shoulda, Machinist, Mocha, and Rcov.
$34.95
post /
You are being
redirected .
get http://localhost:3000/es
Publicaciones de Pragmatic
Su Catálogo de Pragmatic
CoffeeScript
CoffeeScript is JavaScript done right. It provides all of JavaScript's
functionality wrapped in a cleaner, more succinct syntax. In the first
book on this exciting new language, CoffeeScript guru Trevor Burnham
shows you how to hold onto all the power and flexibility of JavaScript
while writing clearer, cleaner, and safer code.
36,00 $US
Programming Ruby 1.9 & 2.0
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,95 $US
Rails Test Prescriptions
Rails Test Prescriptions is a comprehensive guide to testing
Rails applications, covering Test-Driven Development from both a
theoretical perspective (why to test) and from a practical perspective
(how to test effectively). It covers the core Rails testing tools and
procedures for Rails 2 and Rails 3, and introduces popular add-ons,
including Cucumber, Shoulda, Machinist, Mocha, and Rcov.
34,95 $US
rails test
Run options: --seed 5438
# Running:
..........................E
Error:
ProductsControllerTest#test_should_update_product:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/products_controller.rb:47:in `block in update'
app/controllers/products_controller.rb:46:in `update'
test/controllers/products_controller_test.rb:43:in `block in <class:ProductsControllerTest>'
bin/rails test test/controllers/products_controller_test.rb:42
..E
Error:
ProductsControllerTest#test_should_destroy_product:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/products_controller.rb:62:in `destroy'
test/controllers/products_controller_test.rb:57:in `block (2 levels) in <class:ProductsControllerTest>'
test/controllers/products_controller_test.rb:56:in `block in <class:ProductsControllerTest>'
bin/rails test test/controllers/products_controller_test.rb:55
.E
Error:
ProductsControllerTest#test_should_create_product:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/products_controller.rb:30:in `block in create'
app/controllers/products_controller.rb:29:in `create'
test/controllers/products_controller_test.rb:26:in `block (2 levels) in <class:ProductsControllerTest>'
test/controllers/products_controller_test.rb:25:in `block in <class:ProductsControllerTest>'
bin/rails test test/controllers/products_controller_test.rb:24
.....E
Error:
StoreControllerTest#test_markup_needed_for_store.js.coffee_is_in_place:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/concerns/current_cart.rb:9:in `rescue in set_cart'
app/controllers/concerns/current_cart.rb:7:in `set_cart'
test/controllers/store_controller_test.rb:15:in `block in <class:StoreControllerTest>'
bin/rails test test/controllers/store_controller_test.rb:14
E
Error:
StoreControllerTest#test_should_get_index:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/concerns/current_cart.rb:9:in `rescue in set_cart'
app/controllers/concerns/current_cart.rb:7:in `set_cart'
test/controllers/store_controller_test.rb:5:in `block in <class:StoreControllerTest>'
bin/rails test test/controllers/store_controller_test.rb:4
.E
Error:
UsersControllerTest#test_should_update_user:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/users_controller.rb:54:in `block in update'
app/controllers/users_controller.rb:53:in `update'
test/controllers/users_controller_test.rb:45:in `block in <class:UsersControllerTest>'
bin/rails test test/controllers/users_controller_test.rb:44
E
Error:
UsersControllerTest#test_should_create_user:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
app/controllers/users_controller.rb:35:in `block in create'
app/controllers/users_controller.rb:34:in `create'
test/controllers/users_controller_test.rb:22:in `block (2 levels) in <class:UsersControllerTest>'
test/controllers/users_controller_test.rb:20:in `block in <class:UsersControllerTest>'
bin/rails test test/controllers/users_controller_test.rb:19
..F
Failure:
UsersControllerTest#test_should_destroy_user [/home/rubys/git/awdwr/edition4/work-223/depot/test/controllers/users_controller_test.rb:54]:
"User.count" didn't change by -1.
Expected: 1
Actual: 2
bin/rails test test/controllers/users_controller_test.rb:53
.E
Error:
DslUserStoriesTest#test_buying_a_product:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: INSERT INTO "carts" ("created_at", "updated_at") VALUES (?, ?)
app/controllers/concerns/current_cart.rb:9:in `rescue in set_cart'
app/controllers/concerns/current_cart.rb:7:in `set_cart'
test/integration/dsl_user_stories_test.rb:78:in `buys_a'
test/integration/dsl_user_stories_test.rb:43:in `block in test_buying_a_product'
test/integration/dsl_user_stories_test.rb:39:in `test_buying_a_product'
bin/rails test test/integration/dsl_user_stories_test.rb:38
E
Error:
DslUserStoriesTest#test_two_people_buying:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: INSERT INTO "carts" ("created_at", "updated_at") VALUES (?, ?)
app/controllers/concerns/current_cart.rb:9:in `rescue in set_cart'
app/controllers/concerns/current_cart.rb:7:in `set_cart'
test/integration/dsl_user_stories_test.rb:78:in `buys_a'
test/integration/dsl_user_stories_test.rb:58:in `block in test_two_people_buying'
test/integration/dsl_user_stories_test.rb:54:in `test_two_people_buying'
bin/rails test test/integration/dsl_user_stories_test.rb:53
E
Error:
UserStoriesTest#test_buying_a_product:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: DELETE FROM "line_items"
test/integration/user_stories_test.rb:14:in `block in <class:UserStoriesTest>'
bin/rails test test/integration/user_stories_test.rb:12
.........
Finished in 59.633900s, 0.9726 runs/s, 1.6601 assertions/s.
58 runs, 99 assertions, 1 failures, 10 errors, 0 skips
16 Deployment
15.3 Task J3: Translating Checkout