Hi, here are the steps that I performed:
a) rails restapp
b) cd restapp
c) ./script/generate scaffold Person name:string
description:text
d) rake db:migrate
e) add the the following to the top of the routes.rb:
map.root :controller => 'people'
f) ./script/server
g) go to the following address within your browser
http://localhost:3000
h) click the 'New person' link and complete form
i) click the create button and you should see the following
message:
ActiveRecord::RecordNotFound in PeopleController#show
Couldn't find Person with ID=0 RAILS_ROOT:
/Users/conradwt/ruby.dir/projects/restapp
Application Trace | Framework Trace | Full Trace
vendor/rails/activerecord/lib/active_record/base.rb:1375:in
find_one'
vendor/rails/activerecord/lib/active_record/base.rb:1358:infind_from_ids'
vendor/rails/activerecord/lib/active_record/base.rb:537:in
find' app/controllers/people_controller.rb:29:inshow'
Request
Parameters:
{"id"=>"0"}
Show session dump
Response
Headers:
{"cookie"=>[], "Cache-Control"=>"no-cache"}
Next, it the save succeeds but the redirect fails because it's
trying to redirect to /people/0. After further investigation, in
the console:
BEGIN CONSOLE:
darnoc-desktop:restapp conradwt$ script/console Loading
development environment (Rails 2.1.0)
a) person = Person.new
The DL driver for sqlite3-ruby is deprecated and will be removed
in a future release. Please update your installation to use the
Native driver.
#<Person id: nil, name: nil, description: nil, created_at: nil, updated_at: nil>
b) person.name = "Conrad"
"Conrad"
c) person.description = "This is yet another test"
"This is yet another test"
d) person.save
true
e) person
#<Person id: 0, name: "Conrad", description: "This is yet another test", created_at: "2008-08-12 23:00:27", updated_at: "2008-08-12 23:00:27">
END CONSOLE:
Next, from the above, the id field isn't being properly updated
after the save and I'm seeing this with the following setup:
OS: Mac OS 10.5.4
Platform: PPC G5
Ruby Version: ruby 1.8.7 (2008-08-08 patchlevel 71)
[powerpc-darwin9]
Rails Version: Rails 2.1.0
Furthermore, this problem doesn't exist for my laptop with the
following setup:
OS: Mac OS 10.5.4
Platform: Intel Core 2 Duo
Ruby Version: ruby 1.8.7 (2008-08-08 patchlevel 71)
[i686-darwin9]
Rails Version: Rails 2.1.0
Lastly, it appears to be an installation/configuration issue on
the PowerMac G5 in regards to SQLite3 using Rails 2.1.0 becausse
this issue doesn't appear when using MySQL on this platform with
this environment configuration.