Learning Rails
Learning Rails By Simon St. Laurent, Edd Dumbill
November 2008
Pages: 442


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Running Sample Code?
Local_Orbit
post Jun 11 2009, 10:41 PM
Post #1


New Member
*

Group: Members
Posts: 4
Joined: 3-June 09
Member No.: 18,457



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.
Go to the top of the page
 
+Quote Post
simonstl
post Jun 12 2009, 06:18 AM
Post #2


Active Member
**

Group: O'Reilly Editor
Posts: 33
Joined: 17-September 08
Member No.: 1,159



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
Go to the top of the page
 
+Quote Post
Local_Orbit
post Jun 12 2009, 09:38 AM
Post #3


New Member
*

Group: Members
Posts: 4
Joined: 3-June 09
Member No.: 18,457



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?
Go to the top of the page
 
+Quote Post
simonstl
post Jun 12 2009, 01:24 PM
Post #4


Active Member
**

Group: O'Reilly Editor
Posts: 33
Joined: 17-September 08
Member No.: 1,159



QUOTE (Local_Orbit @ Jun 12 2009, 05:38 PM) *
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!
Go to the top of the page
 
+Quote Post
simonstl
post Jun 14 2009, 09:31 AM
Post #5


Active Member
**

Group: O'Reilly Editor
Posts: 33
Joined: 17-September 08
Member No.: 1,159



QUOTE (simonstl @ Jun 12 2009, 09:24 PM) *
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
Go to the top of the page
 
+Quote Post
David Coffield
post Jul 21 2009, 06:27 AM
Post #6


New Member
*

Group: Members
Posts: 1
Joined: 21-July 09
Member No.: 19,277



QUOTE (simonstl @ Jun 14 2009, 09:31 AM) *
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
Go to the top of the page
 
+Quote Post
simonstl
post Jul 28 2009, 12:43 PM
Post #7


Active Member
**

Group: O'Reilly Editor
Posts: 33
Joined: 17-September 08
Member No.: 1,159



QUOTE (David Coffield @ Jul 21 2009, 02:27 PM) *
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.
Go to the top of the page
 
+Quote Post
simonstl
post Aug 29 2009, 01:48 PM
Post #8


Active Member
**

Group: O'Reilly Editor
Posts: 33
Joined: 17-September 08
Member No.: 1,159



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!
Go to the top of the page
 
+Quote Post
tomp7877
post Sep 6 2009, 05:47 AM
Post #9


New Member
*

Group: Members
Posts: 2
Joined: 6-September 09
Member No.: 20,069



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: Sep 6 2009, 07:13 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 22nd November 2009 - 04:19 PM