Agile Web Development with Rails, Edition 4
Agile Web Development with Rails, Edition 4
99 cleanup
26.3 HAML
26.4 JQuery
edit Gemfile
gem 'will_paginate', '~> 3.0'
gem 'activemerchant', '~> 1.10.0'
gem 'haml', '~> 3.1.1'
gem 'jquery-rails', '~> 0.2.2'
bundle install
Using rake (0.9.2.2)
Using abstract (1.0.0)
Using activesupport (3.0.15)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.15)
Using erubis (2.6.6)
Using rack (1.2.5)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.33)
Using actionpack (3.0.15)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.15)
Using braintree (2.16.0)
Using activemerchant (1.10.0)
Using arel (2.0.10)
Using activerecord (3.0.15)
Using activeresource (3.0.15)
Using bundler (1.1.3)
Using highline (1.6.13)
Using net-ssh (2.5.2)
Using net-scp (1.0.4)
Using net-sftp (2.0.5)
Using net-ssh-gateway (1.1.0)
Using capistrano (2.12.0)
Using haml (3.1.6)
Using json (1.7.3)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.0.15)
Using rails (3.0.15)
Using jquery-rails (0.2.7)
Using mysql (2.8.1)
Using sqlite3 (1.3.6)
Using will_paginate (3.0.3)
Updating .gem files in vendor/cache
Could not find activesupport-3.0.15.gem for installation
rails generate jquery:install --ui --force
remove public/javascripts/controls.js
remove public/javascripts/dragdrop.js
remove public/javascripts/effects.js
remove public/javascripts/prototype.js
fetching jQuery (1.5)
create public/javascripts/jquery.js
create public/javascripts/jquery.min.js
fetching jQuery UI (latest 1.x release)
create public/javascripts/jquery-ui.js
create public/javascripts/jquery-ui.min.js
fetching jQuery UJS adapter (github HEAD)
force public/javascripts/rails.js
edit app/views/line_items/create.js.rjs
page.select("#notice").each { |notice| notice.hide }
page.replace_html('cart', render(@cart))
page[:cart].visual_effect :blind_down if @cart.total_items == 1
page[:current_item].visual_effect :highlight,
:startcolor => "#88ff88",
:endcolor => "#114411"
rm app/views/line_items/create.js.rjs
edit app/views/line_items/create.js.erb
$("#notice").hide();
if ($('#cart tr').length == 1) { $('#cart').show('blind', 1000); }
$('#cart').html("<%= escape_javascript(render(@cart)) %>");
$('#current_item').css({'background-color':'#88ff88'}).
animate({'background-color':'#114411'}, 1000);
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") %>
<%= @page_title || t('.title') %>
</div>
<!-- ... -->
rake test
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.............
Finished in 0.527039 seconds.
13 tests, 49 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.........F......................................
Finished in 2.529229 seconds.
1) Failure:
test_should_create_line_item_via_ajax(LineItemsControllerTest) [test/functional/line_items_controller_test.rb:61]:
No RJS statement that replaces or inserts HTML content.
48 tests, 79 assertions, 1 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
...
Finished in 1.657051 seconds.
3 tests, 75 assertions, 0 failures, 0 errors
Errors running test:functionals!
edit test/functional/line_items_controller_test.rb
test "should create line_item via ajax" do
assert_difference('LineItem.count') do
xhr :post, :create, :product_id => products(:ruby).id
end
assert_response :success
assert_select_jquery :html, '#cart' do
assert_select 'tr#current_item td', /Programming Ruby 1.9/
end
end
rake test
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.............
Finished in 0.573079 seconds.
13 tests, 49 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
................................................
Finished in 2.289993 seconds.
48 tests, 79 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
...
Finished in 1.445872 seconds.
3 tests, 75 assertions, 0 failures, 0 errors
edit config/asset_packages.yml
---
javascripts:
- base:
- rails
- application
- jquery-ui
- jquery
stylesheets:
- base:
- scaffold
- depot
rake asset:packager:build_all
Created /home/rubys/git/awdwr/edition4/work-30/depot/public/javascripts/base_packaged.js
Created /home/rubys/git/awdwr/edition4/work-30/depot/public/stylesheets/base_packaged.css
rake db:seed
99 cleanup
26.3 HAML