RailsSpace is now Rails 2.0 compatible!
Posted 4 months ago by Michael Hartl
RailsSpace is now compatible with Rails 2.0, with the following changes:
- In Chapter 2, p. 16, instead of
> rails rails_space
you should use> rails -d mysql rails_space
Another possibility is to edit config/database.yml to make sure all the adapters are mysql. (This is necessary because Rails 2.0.2 changed the default database from MySQL to SQLite3.) - Rails 2.0 uses new filename extensions, such as .html.erb instead of .rhtml.
- In Chapter 10 (Community), you need to install “classic pagination” using
> script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
- In Chapter 13 (Email), p. 390, change
toserver_settingssmtp_settings - In Chapter 15, replace scaffold_resource with just scaffold
- In the RESTful routes of Chapters 15 and 16, instead of things like
andedit_post_path(@blog)
you need to writecomments_path(@blog, @post)
andedit_blog_post_path(@blog)blog_post_comments_path(@blog, @post)
A zip file of the Rails 2.0 compatible RailsSpace code is available for download from the RailsSpace book resources.
UPDATE: It’s also worth noting that the RESTful URLs have changed a bit in Rails 2.0. In particular, the semicolon notation covered in Section 15.1.3 of Chapter 15 has been changed to a regular slash. The arguments we made there that you need something other than a slash to avoid ambiguity still hold; the Rails designers evidently decided that eliminating the weirdness of the semicolon was worth introducing a little ambiguity.
UPDATE 2: There are miscellaneous additional small differences introduced by Rails 2.0, as noted in the comments. Thanks to those who have taken the time to make note of them—we appreciate it.
Comments
There are 23 comments on this post. Post yours →
I just wanted to say THANK YOU! You made the right decision!
Greets, Andy
Merci! This is just great. Support at it’s best!
Cheers
Thanks Michael. Much appreciated. It’s working well.
(BTW, all of the chapters in the book has been helpful, but the REST chapter has been specifically helpful.)
Regards Will
Thanks, Michael, you have a sure sale for your next book. ;)
JG.
Thanks for the positive feedback. Both Aure and I are very busy, and the number of deprecation warnings was very intimidating. After all the effort bringing the book to life under Rails 1.2, the thought of dealing with 2.0 was most unpleasant. I was pleasantly surprised, then, that it really wasn’t that hard once I sat down to do it. I hope you find it useful.
Thank you very much for posting this, it’s going to be a HUGE help.
Hello, Michael.
Do you suppose that Aure’s book will cover the Rails 2.0 version of RailsSpace. Or will we have to do these changes too in the video training?
Whatever the case, I don’t mind but I just would like to know.
Regards, Vitor
The LiveLessons follow the book for consistency, and they were also finished before Rails 2.0 came out. The notes in this blog post therefore apply to the LiveLessons as well.
Hello,
Don’t know if this is the right spot to post this?
I’m brand new to ruby/rails. Just go the book and working through it using netbeans 6.0 and rails 2.0.2.
On page 26, the requested change: map.connect “, :controller => “site” does not seem to work. I used the following based on the comments in routes.rb: map.root :controller => “site” and that seems to work.
Please advise of this post needs to go elsewhere.
Thanks, Joe
@Joe:
The right place to post this sort of question is the RailsSpace Google group. My version of the RailsSpace code works fine with map.connect and Rails 2.0.2. Try posting your question on the forum to see if anyone else has encountered your problem.
Hi, I discovered your book from the REST chapter of your book in the “Professional Ruby collection”, and I just ordered your book&video from amazon.
While waiting, I saw the first free video “Getting started”, and I executed the instructions with Rails 2.0.1.
I want to signal a few minor differences, perhaps to be added in the ‘compatibility list’: 1) views are now named ‘.html.erb’ 2) the statement to uncomment in routes is now: map.root :controller => “site” # “welcome” 3) the Rails team reccomends to replace ‘@contentforlayout’ with ‘yield :layout’ (in the quest to be free to change implementation, and thus preventing users from accessing instance variables).
In any case, congratulations for this calm, thoughtful and methodic tutorial, covering everything, from the small things to REST. [by the way: I will miss that semicolon.. :-)
Raul
Chapter 3.
Rails 2.0 migrations pre-populates the “CreateUsers” class with a “t.timestamps” call, which adds the magic columns :createdat and :updatedat
So.. Listing 3.2 includes “t.timestamps” in “self.up” and there is no need to follow Section “3.2.6 Magic columns”.
Great book BTW!
Ifor.
Minor point. In figure 4.3 the registration page after submission now shows authenticity_token: [and a long number]
I believe this is something new for Rails 2.
I also found one unmentioned minor problem. When I created the User controller, I needed to add a map entry to routes.rb, otherwise I got route not found.
map.connect ‘user’, :controller => ‘user’, :action => ‘index’
Other than that, it is an incredible book. I am transitioning from J2EE to Rails and I have been writing about it in my blog (and others). I just recommended your book for any newbies (http://there.thruhere.net/Larningme_Rails2)
Oopsie. The URL I posted interacted with your textile formatter (Should not include underlines in posted URL’s). Here is the corrected URL (hopefully).
http://there.thruhere.net/LarningMeRails2
I have also posted a couple more entries in my blog that describe how to set up a development environment for Rails 2 using Eclipse.
http://there.thruhere.net/MonkeyingWithEclipseAndRailsPart1 http://there.thruhere.net/MonkeyingWithEclipseAndRailsPart2
By the time I am finished with the series of articles, I should have created one of the best Rails IDE’s out there. Best yet, it will be completely user customizable.
If I get permission from the authors, I hope to add the ability to generate a “RailsSpace like” skeleton as part of the IDE.
But even if they don’t, it will still be a great tool for learning Rails 2.
This solve my problem thank you
Another “feature” of Rails 2.0 is that ENV[“RAILSENV”] does not default to “development” so the section in Chapter 4 with the debug(params) will not work unless you add a ENV[“RAILSENV”] = “development” to the config/environment.rb. Another option would be:
I’ve been working through the book (thanks for the whole style and approach in this!) with Rails 2.0.2 and have found a few things so far (I’m up to chp 6) that might help others doing the same.
I’ve had no problem using sqlite3 as a dev/test database. As in the config/database.yml -
development: adapter: sqlite3 database: db/development.sqlite3 timeout: 5000
When you change the session store to use ActiveRecordStore in the config/environment.rb, you MUST also edit ApplicationController and uncomment the “:secret => …” for the protectfromforgery call or you will get some hard to fathom authentication errors suggesting you might want to use the original cookie store.
When you generate units and controllers the testcases are now Rails subclasses of Test::Unit::TestCase - ActionController::TestCase and ActionSupport::TestCase. These new TestCases embed some functionality that had to be explicit in the RailSpace examples that use original Test::Unit::TestCase -
A note on fixtures - my default Rails installation sets fixtures to not “instantiate” for performance (see Fixtures doc). The ActionController::TestCase doesn’t seem to call my local setup as expected (it never runs) so after much gnashing of teeth I found and added “self.useinstantiatedfixtures = true” to the top of UserControllerTest. Instantiated fixtures like “@valid_user” will now be available.
Also I had to modify some of the login/register tests to test with a valid user that was not in the users.yml fixture - my fixtures are auto-loading into the test database so I couldn’t for example re-register @validuser in a testregister_success.
Oh, and when turning on the before_filter :protect, one of the navigation test cases no longer worked because of the forced redirect.
Thanks!
Thanks for the update and the great book. Seems like classic_pagination is no longer going to be supported and will_paginate should now be used. I’ve figured out how to update my code to use will_paginate but I was wondering if you were going to update the railsspace code to use will_paginate?
I am glad to post my views and points in this blog, but I must say that webmaster of this blog has done a very great job to make his blog more informative and more discussable but unfortunately everything is same here that more than 80% in this and other blogs post their comments for making spam!!!, so i will really all this spam links to Google band tool, because webmaster makes blogs for making discuss and for solving each other problems. thanks http://www.naturalherbalproduct.com
Chapter 7, p. 207, listing 7.23 I had to convert the ten-years-from-now date to string on both sides of the comparison to get assert_equal to be true. Here are my versions of Ruby and Rails:
ruby 1.8.6 (2007-06-07 patchlevel 36) [i586-linux] Rails 2.0.2
p. 234 “hiddenfieldtag” I found that the hidden field must be within the bounds of the … for the associated data or the attribute never showed up.
p. 245 end of listing 8.21, for some reason I could not get correcterrormessage to work unless I assigned the output of sprintf() to some local variable and did an explicit return of that variable. Putting “return” in front of springf() did not work, nor did simply assigning the local variable and relying on an implicit return.
ruby 1.8.6 (2007-06-07 patchlevel 36) [i586-linux] Rails 2.0.2
Post a comment
Required fields in bold.