The Depot Application

The Depot Application

23.5 Forms That Wrap Model Objects 21.2 Routing Requests

23.3 Helpers for Formatting, Linking, and Pagination

cp -vr /home/rubys/git/awdwr/data/code/e1/views/app/views/pager app/views
`/home/rubys/git/awdwr/data/code/e1/views/app/views/pager' -> `app/views/pager'
`/home/rubys/git/awdwr/data/code/e1/views/app/views/pager/user_list.erb' -> `app/views/pager/user_list.erb'
`/home/rubys/git/awdwr/data/code/e1/views/app/views/pager/user_list.html.erb' -> `app/views/pager/user_list.html.erb'
edit Gemfile
# source 'http://rubygems.org'
 
gem 'rails', :path => "/home/rubys/git/rails" # '3.0.0.rc'
 
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
 
gem 'sqlite3-ruby', :require => 'sqlite3'
 
# Use unicorn as the web server
# gem 'unicorn'
 
# Deploy with Capistrano
# gem 'capistrano'
 
# To use debugger
# gem 'ruby-debug'
 
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
 
gem 'will_paginate', '>= 3.0.pre'
 
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
#   gem 'webrat'
# end
bundle show
Gems included by the bundle:
  * abstract (1.0.0)
  * actionmailer (3.0.0.rc)
  * actionpack (3.0.0.rc)
  * activemodel (3.0.0.rc)
  * activerecord (3.0.0.rc)
  * activeresource (3.0.0.rc)
  * activesupport (3.0.0.rc)
  * arel (0.4.0)
  * builder (2.1.2)
  * bundler (1.0.0.rc.3)
  * erubis (2.6.6)
  * i18n (0.4.1)
  * mail (2.2.5)
  * mime-types (1.16)
  * polyglot (0.3.1)
  * rack (1.2.1)
  * rack-mount (0.6.9)
  * rack-test (0.5.4)
  * rails (3.0.0.rc aed698a)
  * railties (3.0.0.rc)
  * rake (0.8.7)
  * sqlite3-ruby (1.3.1)
  * thor (0.14.0)
  * treetop (1.4.8)
  * tzinfo (0.3.22)
  * will_paginate (3.0.pre2)
rails generate model user name:string
      invoke  active_record
      create    db/migrate/20100807132145_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/unit/user_test.rb
      create      test/fixtures/users.yml

Restart the server.

rake db:migrate
mv 20100807132145_create_users.rb 20100301000001_create_users.rb
(in /home/rubys/git/awdwr/work-188/view)
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0015s
==  CreateUsers: migrated (0.0017s) ===========================================
 
echo "PagerController.new.populate" | IRBRC=tmp/irbrc rails console
Loading development environment (Rails 3.0.0.rc)
>> PagerController.new.populate
=> 763
>> 
get /pager/user_list
Name
Adam Keys
Andy Hunt
Brian Marick
Brian McCallister
Chad Fowler
Chris Pine
Daniel Berger
Dave Thomas
David Heinemeier Hansson
Eric Hodel
Esther Derby
Greg Wilson
James Gray
Jeffrey Fredrick
Johanna Rothman
Juliet Thomas
Maik Schmidt
Marcel Molina
Mike Clark
Mike Gunderloy
Mike Mason
Ryan Davis
Scott Barron
Scott Davis
Thomas Fuchs
ZZUser 000
ZZUser 001
ZZUser 002
ZZUser 003
ZZUser 004


get /pager/user_list?page=2
Name
ZZUser 005
ZZUser 006
ZZUser 007
ZZUser 008
ZZUser 009
ZZUser 010
ZZUser 011
ZZUser 012
ZZUser 013
ZZUser 014
ZZUser 015
ZZUser 016
ZZUser 017
ZZUser 018
ZZUser 019
ZZUser 020
ZZUser 021
ZZUser 022
ZZUser 023
ZZUser 024
ZZUser 025
ZZUser 026
ZZUser 027
ZZUser 028
ZZUser 029
ZZUser 030
ZZUser 031
ZZUser 032
ZZUser 033
ZZUser 034


23.5 Forms That Wrap Model Objects 21.2 Routing Requests