#811 √ resolved
Conrad Taylor

Redirect Error After Model Creation

Reported by Conrad Taylor | August 13th, 2008 @ 12:13 AM | in 2.x

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.

Comments and changes to this ticket

  • Wesley Moxam

    Wesley Moxam September 18th, 2008 @ 03:15 PM

    • → Tag changed from “activerecord bug” to “activerecord bug”

    You only mapped the root url to a controller. You need to map the person resource as well.

    map.resources :people

    This should fix your problems.

  • Conrad Taylor

    Conrad Taylor September 28th, 2008 @ 12:17 AM

    Hi, here's the complete routes.rb file that I'm using:

    ActionController::Routing::Routes.draw do |map|

    map.root :controller => 'people'

    map.resources :people

    # Install the default routes as the lowest priority. map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format'

    end

  • Conrad Taylor

    Conrad Taylor September 28th, 2008 @ 12:36 AM

    I have just successfully tested the application using the following configuration:

    OS: Mac OS 10.5.5

    Platform: PPC G5

    Ruby Version: ruby 1.8.7 (2008-08-11 patchlevel 72) [powerpc-darwin9]

    Rails Version: Rails 2.1.1

    SQLite3 Interface: rb-sqlite3 @1.2.1_0 (active)

    SQLite3 Version: sqlite3 @3.6.1_0 (active)

    Thus, this issue is resolved using Rails 2.1.1.

  • Tarmo Tänav

    Tarmo Tänav September 28th, 2008 @ 01:56 AM

    • → State changed from “new” to “resolved”

    As I understand it the issue is resolved, so I'm closing the ticket. Let me know in case I misunderstood.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

Repository is at http://github.com/rails/rails

Check out the development master (Edge Rails):

git clone git://github.com/rails/rails.git

Creating or reviewing a patch

See the contributor guide.

Creating a feature request

Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.

Creating a bug report

When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.

Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.

Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too"..

Shared Ticket Bins

People watching this ticket