small medium large xlarge

23 Dec 2007, 16:09
Steve Jones (14 posts)

Guess I’m just stubborn. I’m working thru AWDWR with Rails 2.0.2. I worked around the scaffold thing in A1 successfully and now am building the cart in C2. Things are dandy until I try my first Add to Cart and get a <ActionController::InvalidAuthenticityToken in StoreController#add_to_cart>. I half expected some trouble as I noticed that the environment.rb was different then noticed that application.rb was changed in 2.0.2 as well. Any clues?

23 Dec 2007, 16:28
Steve Jones (14 posts)

OK, I know, search the entire site for an answer before posting. Yep I found my answer at Just needed to comment out protect_from_forgery.

27 Dec 2007, 23:27
Rick New (1 post)

Hi Steve,

I’m stubborn, too. Don’t want to go back to 1.2…how did you resolve the scaffold issue with Rails 2.0.2?



29 Dec 2007, 00:34
Joel Eidsath (1 post)

I’m using AWDWR with Rails 2.0.2 as well (anybody who wants can drop me a line at jeidsath at gmail if you need help or have suggestions).

The scaffolding wasn’t too hard (although there’s no dynamic updating of views any more). And the Next Page, Previous Page didn’t have any obvious implementation, so I ignored it.

Instead of commenting out protect_from_forgery, I uncommented config.action_controller.session_store in environment.rb (as the book says) and then ignored the book’s suggestions for changes to application.rb. Instead I uncommented :secret in the protect_from_forgery line.

I’m now at the AJAX chapter and bravely forging ahead.

02 Jan 2008, 21:57
Steve Jones (14 posts)

Good work on your environment Joel. Doing it the hard way is the best way to learn. You guys will have to work on without me as I kept my face in AWDWR all thru the holidays and wrapped up depot. Still need to get back to the rest of the book but got sidetracked with another book on social networking sites. I’m doing that one in rails 1.2.3 though. Wish I had taken better notes but the one note I have is about a missing template login/list_users.html.erb in view path depot/app/views/ so I changed list_user.rhtml to list_user.html.erb and bingo! So much ruby, so little time.

04 Jan 2008, 17:42
Brandon Hauff (2 posts)

I have been able to jump through a few hoops getting The AWDWR and Rails 2.02 to work. However, I am at A4 Prettier Listings and cannot do the “ruby script/generate scaffold product admin”

I understand why this is, the generator for scaffold now creates the controller for you and everything, so I executed “ruby script/generate scaffold product” which creates new controllers that are not used in the Depot tutorial. What is the best way to handle the discrepancies between the controllers now.



04 Jan 2008, 18:28
Steve Jones (14 posts)

Be sure to check out this thread and the fairleads blog posting

I had installed the scaffolding plugin

depot>ruby/plugin install

instead of dynamic scaffolding I used @depot>ruby script/generate scaffold Product title:string description:text image_url:string@

04 Jan 2008, 19:37
Brandon Hauff (2 posts)

I have been able to create the scaffold in the same way as you describe Steve, however, the problem is that in the Depot application we use an Admin controller to handle all of the actions related to the shopping cart maintenance. With the new scaffolding the controller handling the actions is the product_controller rather than the admin_controller. I am not sure you to continue with the Depot tutorial under these circumstances.



05 Jan 2008, 14:24
ron campbell (22 posts)

As far as the scaffolding problem, I went to the tutorial listed and created a products scaffold. I then updated the views manually, adding the price column, editing , and validating but am not sure how to add the admin controller, or if to chuck that whole model and use products. I’ve tried to scaffold with two arguments and am told that I have too many arguments now, and have created the admin controller, but I don’t get the extra views and helpers with admin that I need to use these.

I am beginning to wonder if it is worth patching this up, knowing that these problems just snowball later on.

05 Jan 2008, 18:30
Steve Jones (14 posts)

Indeed it did snowball. Don’t know if I wouldn’t recommend rolling back to Rails 1.2.3 or such.

06 Jan 2008, 22:04
ron campbell (22 posts)

Okay Steve, I’ll bite, the only problem with rolling back to an earlier version is that the procedure, at least as outlined in the previously referred blog, doesn’t seem to work for me. I run it, it says that rails 1.2.3 is installed successfully, but when I check it via rails -v — it comes back as Rails 2.0.2 I have tried this from the main directory and within an application directory

here is the command I’ve used # gem install –version=1.2.5 rails –include-dependencies

also rolling it back to # gem install –version=1.2.3 rails –include-dependencies

Both lines run successfully, but the command rails -v still gets rails 2.0.2

Again, is there something I am missing here? if simply rolling it back will put me thru this book, using what they have written, I am all for it, and once again thank you for your help.

David abdemoulaie_pragsmall
07 Jan 2008, 05:27
David Abdemoulaie (1 post)

Ron, the most current version of Rails will remain in your path - thus rails -v should show 2.02.

The rails version used by your application is controlled by config/environment.rb in the following line:

RAILS_GEM_VERSION = ‘1.2.5’ unless defined? RAILS_GEM_VERSION

You can also set the RAILS_GEM_VERSION environment variable as well, I suppose.

15 Jan 2008, 08:19
Bala Paranj (20 posts)

I have upgraded the Depot app to Rails 2.0 version. You can watch the screencast for free at

The modified code is not distributed by me. Bug Dave, he might distribute my code for educational purpose.

18 Jan 2008, 09:35
Simon Krollpfeifer (7 posts)

I would strongly recommend to downgrade the rails version to 1.2.6.

To check the current version(as mentioned above) use $ rails -v to downgrade/deinstall rails 2.0.2 use $ sudo gem uninstall –version=2.0.2 rails

check with rails -v if your current verion is 1.2.6 and not 2.0.2

Nevertheless, I have a small problem with the display of the price. Following the book, my /views/store/index.html looks like:

<% for product in @products -%>
    <div class="entry">
        <%= image_tag(product.image_url) %>
        <h3><%= h(product.title) %></h3>
        <%= product.description %>
        <span class="price"><%= product.price %></span>
<% end %>

The Problem here is, that the price is in the same line as the description. Okay, besides fixing that with an ugly </br>, is there any other way?

25 Jan 2008, 10:27
Daniel José Burd (1 post)

Ajax is working but the page.replace_html is not! I’am in task D - Add a Dash of Ajax it seems that add_to_cart.rjs is not being called. Any help?

07 Feb 2008, 17:35
Ivan Suchý (3 posts)

[Simon Krollpfeifer]

<% for product in @products -%>
    <div class="entry">
        <%= image_tag(product.image_url) %>
        <h3><%= h(product.title) %></h3>
        <div class="desc"><%= product.description %></div>
        <span class="price"><%= product.price %></span>
<% end %>
12 Feb 2008, 18:59
Abrahm Coffman (1 post)

I am going to try and work through the book with rails 2.0.2 as well. Anybody know how to delete/remove an application? I’d like to start from scratch following fairleads blog.

13 Feb 2008, 14:33
Alan Eveson (2 posts)

I had all sorts of fun until I found this thread. I’ve wiped my install, installed the latest Ruby, Gem, Rails, MySQL and Aptana/RadRails, then got Aptana/RadRails working with MySQL. This was all actually fairly hard to do! The products are well documented individually, but getting them all working together is less easy. Still, it’s all FREE so no complaints, just gentle observations. :)

I finally got through the first chapters, the fact that Rails now defaults to SQLite3 slowed me down, not creating my DB slowed me down…

I never did get SQLite3 working, but no matter.

I’ve decided to fight my way through AWDWR with Rails 2.0.2. I learn better in adversity :)

This stuff is so good. I wrote my first program on punch cards in Cobol/Assembler code. Ruby is the first TRULY OO language I’ve encountered. Visual Basic was to OO what a hammer is to a screw.

I only started because my son said he wanted to learn programming, so without thinking I passed him a VB tutorial. A week later I suddenly came to my senses, went into his room, took it out of his hands and put it where it belonged, in the wood burner.

He’s reading Programming Ruby. I’m going through AWDWR. I’m just going to have to try to stay ahead of him.

If he gives me any grief I’ll make him learn Cobol. ;)


13 Feb 2008, 20:28
Alan Eveson (2 posts)

Hi All

I’m not going to bore you all with every fix as I wade through this, only to say check out the following URL whenever you hit a snag. I couldn’t get the validation to work (on page 74) so I checked the validation information here, and found “greater_than” as a part of the numericality test…

14 Feb 2008, 22:14
Frederick C. Lee (1 post)

Env: Mac OS X (Leopard) I’m trying to run the sample codes in rails 2.0.2. Naturally I hit a brick wall and had downgraded to rails 1.2.6; revised the environment.rb accordingly; and replaced ‘require_gem’ to ‘require’.

rails -v
Rails 1.2.6

gem -v

ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]

But now I’ve encountered:

/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- rails (LoadError)
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from ./script/../config/boot.rb:46
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from script/server:2

I’ve traced this error to an exception raised for an unknown path in custom_require.rb:

  def require(path) # :nodoc:
    gem_original_require path
  rescue LoadError => load_error
    if load_error.message =~ /\A[Nn]o such file to load -- #{Regexp.escape path}\z/ and
       spec = Gem.searcher.find(path) then
      Gem.activate(, false, "= #{spec.version}")
      gem_original_require path
      raise load_error

Rather than slamming brick walls, are/will there me more-recent (c2008) AWDWR codes that I can study?

Regards, Ric.

26 Feb 2008, 15:35
Brian P. Hogan (159 posts)

The approach I tell students is to do this before starting the depot app

gem install rails –version=1.2.3 –include-dependencies

rails 1.2.3 depot cd depot

then you’re good to go.

IF you have multiple versions of a gem installed, you can specify the version you want to use. This works great for rails, capistrano, and other tools. Just use x.y.z as a parameter and it’ll get picked up.

Despite what you may have heard, very little has changed with regard to the Rails framework. A lot of things have been added and there are some arguably better ways of building your application… some things have been moved to plugins as well which causes problems for those following older texts. However, you’d need to change very little about your code to move from 1.2.3 to 2.0.2. Updating your app to Rails 1.2.6 is easy, and then it will start logging all the things you need to fix to be 2.0 compatible.

By the time someone writes a book for Rails 2.0, Rails 2.1 will be out and it will be out of date.

Once you have a good solid understanding of the basics of Rails, which this book provides quite nicely, you can easily get up to speed with the current version.

28 Feb 2008, 15:23
Ioannis Prekezes (1 post)

This is a comment to Mr Hogan’s post. The first step to install ROR version 1.2.3 seems to work ok. The second step however: rails 1.2.3 depot does not work as expected. Instead of a depot directory it created a 1.2.3 directory. I am working on OsX 10.5.2.

Finally I uninstalled both 2.0.2 and 1.2.6 versions from my system in order to have depot working in the AWDWR way.

05 Mar 2008, 15:50
Jakub Vosahlo (1 post)

Instead of rails 1.2.3 depot try rails UNDERSCORE1.2.3UNDERSCORE depot. Replace UNDERSCORE with a real underscore character. Had to type it this way as underscore is used for italics formatting here…

That should do the trick…

06 Mar 2008, 18:09
Steven Richard Price (1 post)

I am also stuck at this point.

I think its a poor effort to say “roll back to rails 1.2 or whatever”

thats pretty pants, considering i paid a lot of money for the book only about 2 weeks ago.

but thats a different matter.

i have managed to get the scaffold to work by using this:

depot>ruby script/generate scaffold Product title:string description:text image_url:string

but my next problem is getting the price to display on the screen when i refresh the browser I dont see the price added. its in the database and all that.

cant anyone help me???

08 Mar 2008, 10:07
Simon Krollpfeifer (7 posts)

@ Steven Richard Price It’s not poor effort to say roll back to 1.2.3. When you write a book about a programing language, you can only refer to the version at that time. You can’t foretell any changes ahead.

So, to help you out, what version of rails are you running?

08 Mar 2008, 16:39
Ryan Florence (1 post)

To all who won’t roll back using AWD with Rails …

I did, and I’m loving it. I figure after I get through the book I can go back to the future and learn the changes after I understand what it changed from–rather than trying to understand the current way and the old way all at once with no foundation whatsoever.

11 Mar 2008, 15:06
Michael Mullen (2 posts)

I agree. While the real blame lies with the ruby devs who keep deprecating features, i wish this book had been called “Agile web development with rails 1” so i could have at least saved my money for a newer version.

20 Mar 2008, 01:59
David Wilbur (50 posts)

as Bala said he has walked through converting the app to 2.0. he breaks it out into 5 episodes and it really worth sitting through.


i think you have to go back through the archives to find it by now…

another place that helps is

26 Mar 2008, 10:15
richard trussler (1 post)

@ Steven Richard Price A little bit messy I’m sure, but it looks like you need to run your scaffold again in order to see your prices. Run as you did before but add price:decimal to the command - then overwrite [y] the previous views. I’ve not yet gotten my head around how to add options (precision, scale) correctly so you’ll have to edit your AddPrice migration as per the book.

05 Jun 2008, 00:14
Chuck Hoffman (2 posts)

I wouldn’t characterize it as “rolling back.” Rubygems will keep multiple versions of a gem, so you can have a 2.x and 1.x version of Rails installed on the same machine and work with both. 2.x is still very new and lots of folks are still using 1.x versions of Rails. If you can’t get hold of the 3rd edition, I recommend pressing ahead with AWDWR using a 1.x version; all you need to do is what was described earlier: specify the version to use when you create a new project by adding the extra argument to “rails” at the command line, as the version number surrounded by underscores. This will also place the version to use in the RAILS_GEM_VERSION line of config/environment.rb. You’ll still learn Rails, and then be able to learn what things bits that are different in 2.0 later, especially since you already have it installed.