Pfdrbadge_small Steve Jones 12 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 storecontroller in>. 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?

 
Pfdrbadge_small Steve Jones 12 posts

OK, I know, search the entire site for an answer before posting. Yep I found my answer at http://forums.pragprog.com/forums/22/topics/171?page=1#posts-2071. Just needed to comment out protect_from_forgery.

 
Generic-user-small 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?

Thanks,

Rick

 
Generic-user-small 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.

 
Pfdrbadge_small Steve Jones 12 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.

 
Generic-user-small 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.

Thanks,

Brandon

 
Pfdrbadge_small Steve Jones 12 posts

Be sure to check out this thread http://forums.pragprog.com/forums/22/topics/172 and the fairleads blog posting http://fairleads.blogspot.com/2007/12/rails-20-and-scaffolding-step-by-step.html.

I had installed the scaffolding plugin

depot>ruby/plugin install http://svn.rubyonrails.org/rails/plugins/scaffolding/

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

 
Generic-user-small 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.

Thanks,

Brandon

 
Generic-user-small ron campbell 5 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.

 
Pfdrbadge_small Steve Jones 12 posts

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

 
Generic-user-small ron campbell 5 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
  1. gem install—version=1.2.5 rails—include-dependencies
also rolling it back to
  1. 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.

 
Cookiemonster_small David Abdemo... 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.

 
Generic-user-small Bala Paranj 4 posts

I have upgraded the Depot app to Rails 2.0 version. You can watch the screencast for free at http://www.rubyplus.org/episodes/19-AWDR-Depot-App-using-Rails-2-version.html

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

 
Thm_0888_small Simon Krollp... 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>
    </div>
<% end %>

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

 
Generic-user-small Daniel José ... 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?

 
Generic-user-small 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>
    </div>
<% end %>
 
Generic-user-small 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.

 
Dsc00037smaller_small 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. ;)

Alan

 
Dsc00037smaller_small 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…

http://wiki.rubyonrails.com/rails/recent

 
Calcite_small Frederick C.... 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
1.0.1

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

But now I’ve encountered:

[/Users/Ric/workarea/ruby/depot]script/server
/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(spec.name, false, "= #{spec.version}")
      gem_original_require path
    else
      raise load_error
    end
  end

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

Regards,
Ric.

 
Generic-user-small Brian Hogan 6 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.

 
Generic-user-small Ioannis Prek... 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.

 
Generic-user-small 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…

 
Generic-user-small Steven Richa... 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???

 
Thm_0888_small Simon Krollp... 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?

30 posts, 22 voices

Page: 1 2