O'Reilly Forums: Running Sample Code? - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Running Sample Code?

#1 User is offline   Local_Orbit 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 03-June 09

Posted 11 June 2009 - 10:41 PM

I admit it, I got lazy with the typing and let a few chapters slip by without actually keeping my local guestbook app caught up with the code samples. Now I'd like to run the code samples provided on this site, but I'm running into trouble.

The first problem was my rails version number, as defined in environment.rb. I updated:

"RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION"

to:

"RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION"

Next, I had to change "controllers/application.rb" to controllers/application_controller.rb"

Now I think I'm having trouble with migrations. I had a db table built from ~chapter 6 or so (now chapter 8), and I began by running "rake db:rollback" a few times. Then I ran "rake db:migrate" and tried to run the app. All's well and good, until I tried "new person." This throws an exception to the tune of:

"ActionController::RoutingError in People#new

Showing app/views/people/_form.html.erb where line #5 raised:

person_url failed to generate from {:controller=>"people", :action=>"show", :id=>#<Person id: nil, name: nil, secret: nil, country: nil, email: nil, description: nil, can_send_email: nil, graduation_year: nil, body_temperature: nil, price: nil, birthday: nil, favorite_time: nil, created_at: nil, updated_at: nil, extension: nil>}, expected: {:controller=>"people", :action=>"show"}, diff: {:id=>#<Person id: nil, name: nil, secret: nil, country: nil, email: nil, description: nil, can_send_email: nil, graduation_year: nil, body_temperature: nil, price: nil, birthday: nil, favorite_time: nil, created_at: nil, updated_at: nil, extension: nil>}"

What's my next move here? Or just yell at me for being lazy, that's cool too.
0

#2 User is offline   simonstl 

  • Active Member
  • PipPip
  • Group: O'Reilly Editor
  • Posts: 35
  • Joined: 17-September 08

Posted 12 June 2009 - 06:18 AM

I can't really yell at you for being lazy - I should probably post a complete updated set of examples for 2.3.2. There isn't much change, but you're right that this is annoying.

It sounds like you're doing the right thing, mostly, but it might be easier to let Rails do some of the tricky updating work, as I described at <a href= "http://broadcast.oreilly.com/2009/03/choosing-your-applications-ver.html" >Choosing your Application's Version of Rails</a>.

If that doesn't work more easily for you, let's figure out what to do to move forward.

(There's also a "codeDirectFromBook" directory in the code samples that's pretty much there to let people cut and paste without being trapped in the Rails code I generated.)

Thanks,
Simon

0

#3 User is offline   Local_Orbit 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 03-June 09

Posted 12 June 2009 - 09:38 AM

It's great to know that there's a rake task that may help, but it's not yet doing the trick for me. After changing the environment.rb version number and renaming application_controller.rb, I ran "rake rails:update" and it just returned "(in [filepath]/Rails/guestbook)"

I tried to hit http://localhost:3000/people/new and it's throwing the same error message.

Hm. I could try installing the application with an older version of rails an an argument but I'd really like to get this running on 2.3.2. Any ideas?

0

#4 User is offline   simonstl 

  • Active Member
  • PipPip
  • Group: O'Reilly Editor
  • Posts: 35
  • Joined: 17-September 08

Posted 12 June 2009 - 01:24 PM

QUOTE (Local_Orbit @ Jun 12 2009, 05:38 PM) <{POST_SNAPBACK}>
It's great to know that there's a rake task that may help, but it's not yet doing the trick for me. After changing the environment.rb version number and renaming application_controller.rb, I ran "rake rails:update" and it just returned "(in [filepath]/Rails/guestbook)"

I tried to hit http://localhost:3000/people/new and it's throwing the same error message.

Hm. I could try installing the application with an older version of rails an an argument but I'd really like to get this running on 2.3.2. Any ideas?


I'll take a look this weekend. I'm a little surprised by the routing error, but hopefully I can get it to present the same thing to me.

Thanks! More soon!
0

#5 User is offline   simonstl 

  • Active Member
  • PipPip
  • Group: O'Reilly Editor
  • Posts: 35
  • Joined: 17-September 08

Posted 14 June 2009 - 09:31 AM

QUOTE (simonstl @ Jun 12 2009, 09:24 PM) <{POST_SNAPBACK}>
I'll take a look this weekend. I'm a little surprised by the routing error, but hopefully I can get it to present the same thing to me.

Thanks! More soon!


I can't recreate the bug. Could you let me know which sample code you started from, or even email a zip of your application to simonstl at simonstl.com?

I really should update all the sample code to 2.3.2. I'll do that as soon as I'm over this blasted summer cold!

Thanks,
Simon St.Laurent
0

#6 User is offline   David Coffield 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 21-July 09

Posted 21 July 2009 - 06:27 AM

QUOTE (simonstl @ Jun 14 2009, 09:31 AM) <{POST_SNAPBACK}>
I can't recreate the bug. Could you let me know which sample code you started from, or even email a zip of your application to simonstl at simonstl.com?

I really should update all the sample code to 2.3.2. I'll do that as soon as I'm over this blasted summer cold!

Thanks,
Simon St.Laurent


Hi,

Any idea when the code will be updated? I just bought your book and am getting a bit fed up with none of the code working or copying over some files from it completely screwing up what I'd typed in by hand. Same problem as the guy that opened this thread...

It's spoiling what seems otherwise to be a good book.

Thanks,
David
0

#7 User is offline   simonstl 

  • Active Member
  • PipPip
  • Group: O'Reilly Editor
  • Posts: 35
  • Joined: 17-September 08

Posted 28 July 2009 - 12:43 PM

QUOTE (David Coffield @ Jul 21 2009, 02:27 PM) <{POST_SNAPBACK}>
Any idea when the code will be updated?


Sorry about that - I went from sick to traveling again. I'm home for a while now, and while this weekend is a scheduling disaster, next weekend looks much brighter. I'll post chapters as they get done, and let folks know here.

0

#8 User is offline   simonstl 

  • Active Member
  • PipPip
  • Group: O'Reilly Editor
  • Posts: 35
  • Joined: 17-September 08

Posted 29 August 2009 - 01:48 PM

Sorry to have been so slow, but Chapters 1-8 are now available for both their original 2.1.0 and updated 2.3.3 forms at the examples page.

Hopefully the rest will move more quickly now that I have some momentum!
0

#9 User is offline   tomp7877 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 06-September 09

Posted 06 September 2009 - 05:47 AM

I had put the book and my learning program aside for a few weeks, and tried to plunge straight back in at Chapter 8 by just dup'ing all the code over, and then ran into the same problems as everyone else - version 2.0.
I've just read Simon's last post about updating the samples - I've now installed Rails 2.3.3 and got the latest 2.3.3 code samples, and got the same error as Local_Orbit.
To cut the story short, the 2.3.3 code sample needs the fix as given for pg 124 on the Errata website. http://oreilly.com/catalog/9780596518776/errata/

QUOTE
Replace:

:url => person_path(@person),

with:

:url => { :action => ( @person.new_record? ? "create" : "update" ) },


Change this and it works. BTW I'd like to put in a word of thanks for all the hard work putting this book together and responding to reader comments, even with the little annoyances like this it's the best intro I've seen.

Tom

This post has been edited by tomp7877: 06 September 2009 - 07:13 AM

0

#10 User is offline   udayso 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 01-November 10
  • Gender:Male
  • Interests:Force Factor is a bodybuilding supplement that boost blood flow in our body. The main ingredient of this supplement is Nitric Oxide.

Posted 01 November 2010 - 03:27 AM

I need to study the Dijkstra’s shortest path algorithm...

but cant seem to find the code sample to run it. All i found is codes without header files. help. thanks.........
Force Factor

Attached thumbnail(s)

  • Attached Image: 7418678_b3e2707cdf3aa7f699a10b5eb908cafb.jpg

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users