The Depot Application
Table of Contents
25.1 Sending E-mail
26 Active Resources
</ActiveResource::Redirection: Failed.* 302/> expected but was
<" create ">.
Traceback:
/home/rubys/git/awdwr/work-188-238/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb:307:in `assert_select'
/home/rubys/git/awdwr/checkdepot.rb:1147
Restart the server.
ruby -rubygems /home/rubys/git/rails/railties/bin/rails depot_client
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create db/seeds.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/initializers/cookie_verification_secret.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
edit app/models/product.rb
class Product < ActiveResource::Base
self.site = 'http://dave:secret@localhost:3000/'
end
echo "Product.find(2).title" | IRBRC=tmp/irbrc ruby script/console
*** glibc detected *** irb: realloc(): invalid next size: 0x081e52f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7632803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb763475b]
irb(ruby_xrealloc+0x56)[0x8075696]
irb(rb_str_resize+0x53)[0x80bfcc3]
irb[0x80721c7]
irb(rb_find_file_ext+0x1d2)[0x8072a32]
irb(rb_require_safe+0x12d)[0x806726d]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x8067be6]
irb[0x806806b]
irb[0x8059334]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x805ef39]
irb[0x806b95e]
irb(rb_yield+0x21)[0x806cdc1]
irb(rb_ary_each+0x31)[0x80d1c51]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x8060e11]
irb[0x80618ce]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x806d630]
irb(ruby_exec+0x16)[0x806d656]
irb(ruby_run+0x21)[0x806d9a1]
irb[0x805527f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb75db450]
irb[0x80551d1]
======= Memory map: ========
08048000-08102000 r-xp 00000000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08102000-08103000 rw-p 000ba000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08103000-081f8000 rw-p 08103000 00:00 0 [heap]
b7300000-b7321000 rw-p b7300000 00:00 0
b7321000-b7400000 ---p b7321000 00:00 0
b74b1000-b74de000 r-xp 00000000 08:05 2965573 /lib/libncurses.so.5.6
b74de000-b74e1000 rw-p 0002c000 08:05 2965573 /lib/libncurses.so.5.6
b74e1000-b750d000 r-xp 00000000 08:05 2965623 /lib/libreadline.so.5.2
b750d000-b7511000 rw-p 0002c000 08:05 2965623 /lib/libreadline.so.5.2
b7511000-b7512000 rw-p b7511000 00:00 0
b7522000-b75ad000 rw-p b7522000 00:00 0
b75ad000-b75c1000 r-xp 00000000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b75c1000-b75c3000 rw-p 00013000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b75c3000-b75c5000 rw-p b75c3000 00:00 0
b75c5000-b770e000 r-xp 00000000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b770e000-b770f000 r--p 00149000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b770f000-b7711000 rw-p 0014a000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b7711000-b7714000 rw-p b7711000 00:00 0
b7714000-b7737000 r-xp 00000000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b7737000-b7739000 rw-p 00023000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b7739000-b7742000 r-xp 00000000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7742000-b7744000 rw-p 00008000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7744000-b776c000 rw-p b7744000 00:00 0
b776c000-b776e000 r-xp 00000000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b776e000-b7770000 rw-p 00001000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b7770000-b7777000 r-xp 00000000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b7777000-b7779000 rw-p 00006000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b7779000-b7783000 r-xp 00000000 08:05 2969156 /lib/libgcc_s.so.1
b7783000-b7784000 rw-p 0000a000 08:05 2969156 /lib/libgcc_s.so.1
b7784000-b7788000 r-xp 00000000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b7788000-b7789000 rw-p 00003000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b7789000-b778b000 rw-p b7789000 00:00 0
b778b000-b778c000 r-xp b778b000 00:00 0 [vdso]
b778c000-b77a6000 r-xp 00000000 08:05 1786011 /lib/ld-2.7.so
b77a6000-b77a8000 rw-p 00019000 08:05 1786011 /lib/ld-2.7.so
bf986000-bf99b000 rw-p bffeb000 00:00 0 [stack]
Aborted
edit app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
layout "store"
before_filter :authorize, :except => :login
#...
protected
def authorize
unless User.find_by_id(session[:user_id])
if session[:user_id] != :logged_out
authenticate_or_request_with_http_basic('Depot') do |username, password|
user = User.authenticate(username, password)
session[:user_id] = user.id if user
end
else
flash[:notice] = "Please log in"
redirect_to :controller => 'admin', :action => 'login'
end
end
end
def set_locale
session[:locale] = params[:locale] if params[:locale]
I18n.locale = session[:locale] || I18n.default_locale
locale_path = "#{LOCALES_DIRECTORY}#{I18n.locale}.yml"
unless I18n.load_path.include? locale_path
I18n.load_path << locale_path
I18n.backend.send(:init_translations)
end
rescue Exception => err
logger.error err
flash.now[:notice] = "#{I18n.locale} translation not available"
I18n.load_path -= [locale_path]
I18n.locale = session[:locale] = I18n.default_locale
end
end
edit app/controllers/admin_controller.rb
class AdminController < ApplicationController
# just display the form and wait for user to
# enter a name and password
def login
if request.post?
user = User.authenticate(params[:name], params[:password])
if user
session[:user_id] = user.id
redirect_to(:action => "index")
else
flash.now[:notice] = "Invalid user/password combination"
end
end
end
def logout
session[:user_id] = :logged_out
flash[:notice] = "Logged out"
redirect_to(:action => "login")
end
def index
@total_orders = Order.count
end
end
edit app/controllers/line_items_controller.rb
def create
params[:line_item][:order_id] ||= params[:order_id]
@line_item = LineItem.new(params[:line_item])
respond_to do |format|
if @line_item.save
format.html { redirect_to(@line_item, :notice => 'LineItem was successfully created.') }
format.xml { render :xml => @line_item, :status => :created,
:location => @line_item }
else
format.html { render :action => "new" }
format.xml { render :xml => @line_item.errors,
:status => :unprocessable_entity }
end
end
end
edit config/routes.rb
ActionController::Routing::Routes.draw do |map|
map.resources :users
map.resources :line_items
map.resources :orders, :has_many => :line_items
map.resources :products
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# end
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing or commenting them out if you're using named routes and resources.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
Restart the server.
echo "Product.find(2).title" | IRBRC=tmp/irbrc ruby script/console
*** glibc detected *** irb: realloc(): invalid next size: 0x081e52f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb75f7803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb75f975b]
irb(ruby_xrealloc+0x56)[0x8075696]
irb(rb_str_resize+0x53)[0x80bfcc3]
irb[0x80721c7]
irb(rb_find_file_ext+0x1d2)[0x8072a32]
irb(rb_require_safe+0x12d)[0x806726d]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x8067be6]
irb[0x806806b]
irb[0x8059334]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x805ef39]
irb[0x806b95e]
irb(rb_yield+0x21)[0x806cdc1]
irb(rb_ary_each+0x31)[0x80d1c51]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x8060e11]
irb[0x80618ce]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x806d630]
irb(ruby_exec+0x16)[0x806d656]
irb(ruby_run+0x21)[0x806d9a1]
irb[0x805527f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb75a0450]
irb[0x80551d1]
======= Memory map: ========
08048000-08102000 r-xp 00000000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08102000-08103000 rw-p 000ba000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08103000-081f8000 rw-p 08103000 00:00 0 [heap]
b7300000-b7321000 rw-p b7300000 00:00 0
b7321000-b7400000 ---p b7321000 00:00 0
b7476000-b74a3000 r-xp 00000000 08:05 2965573 /lib/libncurses.so.5.6
b74a3000-b74a6000 rw-p 0002c000 08:05 2965573 /lib/libncurses.so.5.6
b74a6000-b74d2000 r-xp 00000000 08:05 2965623 /lib/libreadline.so.5.2
b74d2000-b74d6000 rw-p 0002c000 08:05 2965623 /lib/libreadline.so.5.2
b74d6000-b74d7000 rw-p b74d6000 00:00 0
b74e7000-b7572000 rw-p b74e7000 00:00 0
b7572000-b7586000 r-xp 00000000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7586000-b7588000 rw-p 00013000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7588000-b758a000 rw-p b7588000 00:00 0
b758a000-b76d3000 r-xp 00000000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76d3000-b76d4000 r--p 00149000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76d4000-b76d6000 rw-p 0014a000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76d6000-b76d9000 rw-p b76d6000 00:00 0
b76d9000-b76fc000 r-xp 00000000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b76fc000-b76fe000 rw-p 00023000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b76fe000-b7707000 r-xp 00000000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7707000-b7709000 rw-p 00008000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7709000-b7731000 rw-p b7709000 00:00 0
b7731000-b7733000 r-xp 00000000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b7733000-b7735000 rw-p 00001000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b7735000-b773c000 r-xp 00000000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b773c000-b773e000 rw-p 00006000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b773e000-b7748000 r-xp 00000000 08:05 2969156 /lib/libgcc_s.so.1
b7748000-b7749000 rw-p 0000a000 08:05 2969156 /lib/libgcc_s.so.1
b7749000-b774d000 r-xp 00000000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b774d000-b774e000 rw-p 00003000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b774e000-b7750000 rw-p b774e000 00:00 0
b7750000-b7751000 r-xp b7750000 00:00 0 [vdso]
b7751000-b776b000 r-xp 00000000 08:05 1786011 /lib/ld-2.7.so
b776b000-b776d000 rw-p 00019000 08:05 1786011 /lib/ld-2.7.so
bfc60000-bfc75000 rw-p bffeb000 00:00 0 [stack]
Aborted
echo "p = Product.find(2)\\nputs p.price\\np.price-=5\\np.save" | IRBRC=tmp/irbrc ruby script/console
*** glibc detected *** irb: realloc(): invalid next size: 0x081e52f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7597803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb759975b]
irb(ruby_xrealloc+0x56)[0x8075696]
irb(rb_str_resize+0x53)[0x80bfcc3]
irb[0x80721c7]
irb(rb_find_file_ext+0x1d2)[0x8072a32]
irb(rb_require_safe+0x12d)[0x806726d]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x8067be6]
irb[0x806806b]
irb[0x8059334]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x805ef39]
irb[0x806b95e]
irb(rb_yield+0x21)[0x806cdc1]
irb(rb_ary_each+0x31)[0x80d1c51]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x8060e11]
irb[0x80618ce]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x806d630]
irb(ruby_exec+0x16)[0x806d656]
irb(ruby_run+0x21)[0x806d9a1]
irb[0x805527f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7540450]
irb[0x80551d1]
======= Memory map: ========
08048000-08102000 r-xp 00000000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08102000-08103000 rw-p 000ba000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08103000-081f8000 rw-p 08103000 00:00 0 [heap]
b7300000-b7321000 rw-p b7300000 00:00 0
b7321000-b7400000 ---p b7321000 00:00 0
b7416000-b7443000 r-xp 00000000 08:05 2965573 /lib/libncurses.so.5.6
b7443000-b7446000 rw-p 0002c000 08:05 2965573 /lib/libncurses.so.5.6
b7446000-b7472000 r-xp 00000000 08:05 2965623 /lib/libreadline.so.5.2
b7472000-b7476000 rw-p 0002c000 08:05 2965623 /lib/libreadline.so.5.2
b7476000-b7477000 rw-p b7476000 00:00 0
b7487000-b7512000 rw-p b7487000 00:00 0
b7512000-b7526000 r-xp 00000000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7526000-b7528000 rw-p 00013000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7528000-b752a000 rw-p b7528000 00:00 0
b752a000-b7673000 r-xp 00000000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b7673000-b7674000 r--p 00149000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b7674000-b7676000 rw-p 0014a000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b7676000-b7679000 rw-p b7676000 00:00 0
b7679000-b769c000 r-xp 00000000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b769c000-b769e000 rw-p 00023000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b769e000-b76a7000 r-xp 00000000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b76a7000-b76a9000 rw-p 00008000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b76a9000-b76d1000 rw-p b76a9000 00:00 0
b76d1000-b76d3000 r-xp 00000000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b76d3000-b76d5000 rw-p 00001000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b76d5000-b76dc000 r-xp 00000000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b76dc000-b76de000 rw-p 00006000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b76de000-b76e8000 r-xp 00000000 08:05 2969156 /lib/libgcc_s.so.1
b76e8000-b76e9000 rw-p 0000a000 08:05 2969156 /lib/libgcc_s.so.1
b76e9000-b76ed000 r-xp 00000000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b76ed000-b76ee000 rw-p 00003000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b76ee000-b76f0000 rw-p b76ee000 00:00 0
b76f0000-b76f1000 r-xp b76f0000 00:00 0 [vdso]
b76f1000-b770b000 r-xp 00000000 08:05 1786011 /lib/ld-2.7.so
b770b000-b770d000 rw-p 00019000 08:05 1786011 /lib/ld-2.7.so
bfed3000-bfee8000 rw-p bffeb000 00:00 0 [stack]
Aborted
get /store
Pragmatic Bookshelf
Your Pragmatic Catalog
Pragmatic Project Automation
Pragmatic Project Automation shows you how to improve the
consistency and repeatability of your project's procedures using
automation to reduce risk and errors.
Simply put, we're going to put this thing called a computer to work
for you doing the mundane (but important) project stuff. That means
you'll have more time and energy to do the really
exciting---and difficult---stuff, like writing quality code.
Pragmatic Unit Testing (C#)
Pragmatic programmers use feedback to drive their development and
personal processes. The most valuable feedback you can get while
coding comes from unit testing.
Without good tests in place, coding can become a frustrating game of
"whack-a-mole." That's the carnival game where the player strikes at a
mechanical mole; it retreats and another mole pops up on the opposite side
of the field. The moles pop up and down so fast that you end up flailing
your mallet helplessly as the moles continue to pop up where you least
expect them.
Pragmatic Version Control
This book is a recipe-based approach to using Subversion that will
get you up and running quickly---and correctly. All projects need
version control: it's a foundational piece of any project's
infrastructure. Yet half of all project teams in the U.S. don't use
any version control at all. Many others don't use it well, and end
up experiencing time-consuming problems.
edit app/models/order.rb
class Order < ActiveResource::Base
self.site = 'http://dave:secret@localhost:3000/'
end
echo "Order.find(1).name\\nOrder.find(1).line_items\\n" | IRBRC=tmp/irbrc ruby script/console
*** glibc detected *** irb: realloc(): invalid next size: 0x081e52f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7593803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb759575b]
irb(ruby_xrealloc+0x56)[0x8075696]
irb(rb_str_resize+0x53)[0x80bfcc3]
irb[0x80721c7]
irb(rb_find_file_ext+0x1d2)[0x8072a32]
irb(rb_require_safe+0x12d)[0x806726d]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x8067be6]
irb[0x806806b]
irb[0x8059334]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x805ef39]
irb[0x806b95e]
irb(rb_yield+0x21)[0x806cdc1]
irb(rb_ary_each+0x31)[0x80d1c51]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x8060e11]
irb[0x80618ce]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x806d630]
irb(ruby_exec+0x16)[0x806d656]
irb(ruby_run+0x21)[0x806d9a1]
irb[0x805527f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb753c450]
irb[0x80551d1]
======= Memory map: ========
08048000-08102000 r-xp 00000000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08102000-08103000 rw-p 000ba000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08103000-081f8000 rw-p 08103000 00:00 0 [heap]
b7300000-b7321000 rw-p b7300000 00:00 0
b7321000-b7400000 ---p b7321000 00:00 0
b7412000-b743f000 r-xp 00000000 08:05 2965573 /lib/libncurses.so.5.6
b743f000-b7442000 rw-p 0002c000 08:05 2965573 /lib/libncurses.so.5.6
b7442000-b746e000 r-xp 00000000 08:05 2965623 /lib/libreadline.so.5.2
b746e000-b7472000 rw-p 0002c000 08:05 2965623 /lib/libreadline.so.5.2
b7472000-b7473000 rw-p b7472000 00:00 0
b7483000-b750e000 rw-p b7483000 00:00 0
b750e000-b7522000 r-xp 00000000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7522000-b7524000 rw-p 00013000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7524000-b7526000 rw-p b7524000 00:00 0
b7526000-b766f000 r-xp 00000000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b766f000-b7670000 r--p 00149000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b7670000-b7672000 rw-p 0014a000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b7672000-b7675000 rw-p b7672000 00:00 0
b7675000-b7698000 r-xp 00000000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b7698000-b769a000 rw-p 00023000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b769a000-b76a3000 r-xp 00000000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b76a3000-b76a5000 rw-p 00008000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b76a5000-b76cd000 rw-p b76a5000 00:00 0
b76cd000-b76cf000 r-xp 00000000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b76cf000-b76d1000 rw-p 00001000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b76d1000-b76d8000 r-xp 00000000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b76d8000-b76da000 rw-p 00006000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b76da000-b76e4000 r-xp 00000000 08:05 2969156 /lib/libgcc_s.so.1
b76e4000-b76e5000 rw-p 0000a000 08:05 2969156 /lib/libgcc_s.so.1
b76e5000-b76e9000 r-xp 00000000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b76e9000-b76ea000 rw-p 00003000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b76ea000-b76ec000 rw-p b76ea000 00:00 0
b76ec000-b76ed000 r-xp b76ec000 00:00 0 [vdso]
b76ed000-b7707000 r-xp 00000000 08:05 1786011 /lib/ld-2.7.so
b7707000-b7709000 rw-p 00019000 08:05 1786011 /lib/ld-2.7.so
bf85e000-bf873000 rw-p bffeb000 00:00 0 [stack]
Aborted
edit app/models/line_item.rb
class LineItem < ActiveResource::Base
self.site = 'http://dave:secret@localhost:3000/orders/:order_id'
end
get /admin/logout
HTTP Basic: Access denied.
get /admin/login
Pragmatic Bookshelf
post /admin/login
name => dave
password => secret
You are being
redirected .
get http://localhost:3000/admin
Pragmatic Bookshelf
Welcome
It's Fri May 28 09:32:38 -0400 2010
We have 2 orders.
get /orders/1/line_items.xml
<?xml version="1.0" encoding="UTF-8"?>
<line-items type="array">
<line-item>
<created-at type="datetime">2010-05-28T13:23:22Z</created-at>
<id type="integer">1</id>
<order-id type="integer">1</order-id>
<product-id type="integer">3</product-id>
<quantity type="integer">1</quantity>
<total-price type="decimal">28.5</total-price>
<updated-at type="datetime">2010-05-28T13:23:22Z</updated-at>
</line-item>
<line-item>
<created-at type="datetime">2010-05-28T13:24:51Z</created-at>
<id type="integer">2</id>
<order-id type="integer">2</order-id>
<product-id type="integer">2</product-id>
<quantity type="integer">2</quantity>
<total-price type="decimal">59.9</total-price>
<updated-at type="datetime">2010-05-28T13:24:51Z</updated-at>
</line-item>
</line-items>
echo "LineItem.find(:all, :params => {:order_id=>1})" | IRBRC=tmp/irbrc ruby script/console
*** glibc detected *** irb: realloc(): invalid next size: 0x081e52f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb75f6803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb75f875b]
irb(ruby_xrealloc+0x56)[0x8075696]
irb(rb_str_resize+0x53)[0x80bfcc3]
irb[0x80721c7]
irb(rb_find_file_ext+0x1d2)[0x8072a32]
irb(rb_require_safe+0x12d)[0x806726d]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x8067be6]
irb[0x806806b]
irb[0x8059334]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x805ef39]
irb[0x806b95e]
irb(rb_yield+0x21)[0x806cdc1]
irb(rb_ary_each+0x31)[0x80d1c51]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x8060e11]
irb[0x80618ce]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x806d630]
irb(ruby_exec+0x16)[0x806d656]
irb(ruby_run+0x21)[0x806d9a1]
irb[0x805527f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb759f450]
irb[0x80551d1]
======= Memory map: ========
08048000-08102000 r-xp 00000000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08102000-08103000 rw-p 000ba000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08103000-081f8000 rw-p 08103000 00:00 0 [heap]
b7300000-b7321000 rw-p b7300000 00:00 0
b7321000-b7400000 ---p b7321000 00:00 0
b7475000-b74a2000 r-xp 00000000 08:05 2965573 /lib/libncurses.so.5.6
b74a2000-b74a5000 rw-p 0002c000 08:05 2965573 /lib/libncurses.so.5.6
b74a5000-b74d1000 r-xp 00000000 08:05 2965623 /lib/libreadline.so.5.2
b74d1000-b74d5000 rw-p 0002c000 08:05 2965623 /lib/libreadline.so.5.2
b74d5000-b74d6000 rw-p b74d5000 00:00 0
b74e6000-b7571000 rw-p b74e6000 00:00 0
b7571000-b7585000 r-xp 00000000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7585000-b7587000 rw-p 00013000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b7587000-b7589000 rw-p b7587000 00:00 0
b7589000-b76d2000 r-xp 00000000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76d2000-b76d3000 r--p 00149000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76d3000-b76d5000 rw-p 0014a000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76d5000-b76d8000 rw-p b76d5000 00:00 0
b76d8000-b76fb000 r-xp 00000000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b76fb000-b76fd000 rw-p 00023000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b76fd000-b7706000 r-xp 00000000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7706000-b7708000 rw-p 00008000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7708000-b7730000 rw-p b7708000 00:00 0
b7730000-b7732000 r-xp 00000000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b7732000-b7734000 rw-p 00001000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b7734000-b773b000 r-xp 00000000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b773b000-b773d000 rw-p 00006000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b773d000-b7747000 r-xp 00000000 08:05 2969156 /lib/libgcc_s.so.1
b7747000-b7748000 rw-p 0000a000 08:05 2969156 /lib/libgcc_s.so.1
b7748000-b774c000 r-xp 00000000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b774c000-b774d000 rw-p 00003000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b774d000-b774f000 rw-p b774d000 00:00 0
b774f000-b7750000 r-xp b774f000 00:00 0 [vdso]
b7750000-b776a000 r-xp 00000000 08:05 1786011 /lib/ld-2.7.so
b776a000-b776c000 rw-p 00019000 08:05 1786011 /lib/ld-2.7.so
bfe70000-bfe85000 rw-p bffeb000 00:00 0 [stack]
Aborted
echo "li = LineItem.find(:all, :params => {:order_id=>1}).first\\nputs li.total_price\\nli.total_price*=0.8\\nli.save\\nli2 = LineItem.new(:order_id=>1, :product_id=>2, :quantity=>1, :total_price=>0.0)\\nli2.save" | IRBRC=tmp/irbrc ruby script/console
*** glibc detected *** irb: realloc(): invalid next size: 0x081e52f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb760e803]
/lib/tls/i686/cmov/libc.so.6(realloc+0x10b)[0xb761075b]
irb(ruby_xrealloc+0x56)[0x8075696]
irb(rb_str_resize+0x53)[0x80bfcc3]
irb[0x80721c7]
irb(rb_find_file_ext+0x1d2)[0x8072a32]
irb(rb_require_safe+0x12d)[0x806726d]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x8067be6]
irb[0x806806b]
irb[0x8059334]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ecf3]
irb[0x805ef39]
irb[0x806b95e]
irb(rb_yield+0x21)[0x806cdc1]
irb(rb_ary_each+0x31)[0x80d1c51]
irb[0x8063ab6]
irb[0x8063d81]
irb[0x8060e11]
irb[0x80618ce]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x80639fc]
irb[0x8063d81]
irb[0x805ebc6]
irb[0x806d630]
irb(ruby_exec+0x16)[0x806d656]
irb(ruby_run+0x21)[0x806d9a1]
irb[0x805527f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb75b7450]
irb[0x80551d1]
======= Memory map: ========
08048000-08102000 r-xp 00000000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08102000-08103000 rw-p 000ba000 08:05 3443180 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/bin/ruby
08103000-081f8000 rw-p 08103000 00:00 0 [heap]
b7300000-b7321000 rw-p b7300000 00:00 0
b7321000-b7400000 ---p b7321000 00:00 0
b748d000-b74ba000 r-xp 00000000 08:05 2965573 /lib/libncurses.so.5.6
b74ba000-b74bd000 rw-p 0002c000 08:05 2965573 /lib/libncurses.so.5.6
b74bd000-b74e9000 r-xp 00000000 08:05 2965623 /lib/libreadline.so.5.2
b74e9000-b74ed000 rw-p 0002c000 08:05 2965623 /lib/libreadline.so.5.2
b74ed000-b74ee000 rw-p b74ed000 00:00 0
b74fe000-b7589000 rw-p b74fe000 00:00 0
b7589000-b759d000 r-xp 00000000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b759d000-b759f000 rw-p 00013000 08:05 2998328 /lib/tls/i686/cmov/libpthread-2.7.so
b759f000-b75a1000 rw-p b759f000 00:00 0
b75a1000-b76ea000 r-xp 00000000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76ea000-b76eb000 r--p 00149000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76eb000-b76ed000 rw-p 0014a000 08:05 2998314 /lib/tls/i686/cmov/libc-2.7.so
b76ed000-b76f0000 rw-p b76ed000 00:00 0
b76f0000-b7713000 r-xp 00000000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b7713000-b7715000 rw-p 00023000 08:05 2998318 /lib/tls/i686/cmov/libm-2.7.so
b7715000-b771e000 r-xp 00000000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b771e000-b7720000 rw-p 00008000 08:05 2998316 /lib/tls/i686/cmov/libcrypt-2.7.so
b7720000-b7748000 rw-p b7720000 00:00 0
b7748000-b774a000 r-xp 00000000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b774a000-b774c000 rw-p 00001000 08:05 2998317 /lib/tls/i686/cmov/libdl-2.7.so
b774c000-b7753000 r-xp 00000000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b7753000-b7755000 rw-p 00006000 08:05 2998330 /lib/tls/i686/cmov/librt-2.7.so
b7755000-b775f000 r-xp 00000000 08:05 2969156 /lib/libgcc_s.so.1
b775f000-b7760000 rw-p 0000a000 08:05 2969156 /lib/libgcc_s.so.1
b7760000-b7764000 r-xp 00000000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b7764000-b7765000 rw-p 00003000 08:05 754126 /home/rubys/.rvm/rubies/ruby-1.8.8-r28050/lib/ruby/1.8/i686-linux/readline.so
b7765000-b7767000 rw-p b7765000 00:00 0
b7767000-b7768000 r-xp b7767000 00:00 0 [vdso]
b7768000-b7782000 r-xp 00000000 08:05 1786011 /lib/ld-2.7.so
b7782000-b7784000 rw-p 00019000 08:05 1786011 /lib/ld-2.7.so
bf8e1000-bf8f6000 rw-p bffeb000 00:00 0 [stack]
Aborted
Table of Contents
25.1 Sending E-mail