Beginning Ruby on Rails E-Commerce : Errata Help

Page 103, the migration for adding the cover column does not seem to
work.

$ script/generate migration add_book_cover_column

class AddBookCoverColumn < ActiveRecord::Migration
def self.up
add_column :books, :cover_image, :string
end
def self.down
remove_column :books, :cover_image
end
end

When I do the “rake migrate”, I get table books already exists error
message.
Can someone tell me how to get this to work? TIA.

I’m almost there.
did you gett errors when running the test on page 101?

ruby test/integration/book_test.rb

it ran for me before adding the select and option tags, now I get

expected tag, but no tag found matching {:content=>“Ruby for
Dummies”, :tag=>“td”} in: …(html code for the page)
when i run it.

I’ve copied the code fron the source and it still fails.
it works when i use the web interface… I’m lost

I remember something similar to that error. I will post the actual error
message when I get back home. For the time being you can comment out the
assertions that is checking for those tags.

This is really annoying, author has not responded to my emails. Apress
does
not have any forum for errata help. Do the authors and the publisher
still
live in caves? Book is good but the support is poor compared to other
publishers like Pragmatic programmers and Manning.

I have encountered two problems so far, one with migration and the other
with assertion that checks for html tags. To see what was going on with
the
migration, I did: rake db:migrate --trace

For some weird reason it seems to think that it has to run the migration
for
create tables (the previous migration) as well as the add cover_image
column
migration. For the time being, I commented out the entire file for the
create books table and author_books table in the migration before add
cover_image column migration.

Holly Thomas wrote:

When I do the “rake migrate”, I get table books already exists error
message.
Can someone tell me how to get this to work? TIA.

Hi Holly,

When all else fails, you can use

“rake db:migrate VERSION=0”

to reset back to empty, and then “rake db:migrate” to try again.

Have you tried this yet ?

A.

this line is causing it to fail.
assert_tag :tag => ‘td’, :content => parameters[:book][:title]

when i comment it out it runs.
now like i said before that when i ran this test from 93 it ran fine.
this is why i am confused.

I bought the companion e-book on friday and still haven’t recieved my
pdf yet. I’m not to happy with their ‘support’ either

my migration just worked.
i’m running Locomotive 2.0.8
(http://locomotive.raaum.org/bundles/index.html)
I followed what’s in the book.

$ script/generate migration add_book_cover_column


class AddBookCoverColumn < ActiveRecord::Migration
def self.up
add_column :books, :cover_image, :string
end

def self.down
remove_column :books, :cover_image
end
end


$ rake migrate
(in /Users/johnivanoff/Sites/emporium)
== AddBookCoverColumn: migrating

– add_column(:books, :cover_image, :string)
→ 0.0745s
== AddBookCoverColumn: migrated (0.0747s)

Loaded suite
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/rake
Started

Finished in 0.000254 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

I get the following error message:

expected tag, but no tag found matching {:content=>“Ruby for Dummies”,
:tag=>“td”} in:

when the assertion:

assert_tag :tag => ‘option’, :attributes => { :value => publisher.id }

gets executed. So, it looks like we both have the same problem. I have
commented out the following two assert statements for the time being:

assert_tag :tag => ‘option’, :attributes => { :value => publisher.id }
assert_tag :tag => ‘select’, :attributes => { :id =>
‘book[author_ids][]’ }

Heads up on another issue, the book does not tell you to install
RedCloth. You will run into problem on page number 128. So you must
install RedCloth to use the textilize method. On Mac I did this: sudo
gem install RedCloth

Thanks for the heads up.

One of the things that the book does not mention is that the fixtures
that
you use must have proper data. Copy all the fixtures files from the
downloaded source and give it a shot. It may not solve all problems but
atleast we have exhausted all options.

After reading all the posts on this thread, it appears I am having the
same problems with any tests that check for assert_tag ‘’, :content
=> ‘(some content)’. I have also gone ahead and commented the assert_tag
out and then the tests work just fine, but it is really annoying.
Especially since it is documented in the book. I have also copied the
files from the source code I downloaded from Apress and it still fails.
Has anyone been able to get this to work or at least figure out what is
causing the error? Please help!

I have tried to fix this problem extensively without any success.
Comment out the line with assert_tag and keep going.
One thing very frustrating about this otherwise excellent book
(Beginning Ruby on Rails E-Commerce) is that the authors have not set
up a site to provide feedback/fixes etc.
Bharat

There is another related thread on this list. Change the test_process.rb
to
the implementation shown below:

— vendor/rails/actionpack/lib/action_controller/test_process.rb
def html_document
HTML::Document.new(@response.body)
end

Let us know if that fixes the problem.

They have a companion site at http://www.railsecommerce.com/ but I
don’t know if there’s a defined mechanism for feedback. Perhaps an
e-mail to Jarkko will suffice?

There seem to be some problems with some of the examples, so hopefully
they can get something up soon on there! The mailing list isn’t the
best place for these kinds of things (especially since Jarkko isn’t
involved in these conversations!).

Good luck,
Jeremy

This weekend was ruined because of this book. I am actually exhausted
from
trying to learn from this book. I worked this book till page 112 and
deleted
everything and started all over again to see if I can get it running.
This
book is just draining my energy.

I would suggest others to stay away from this book. Unless you have lot
of
time and energy to waste. You can think about buying this book if the
publisher comes up with a revised edition that fixes all the problems.

Bala P. wrote:

There is another related thread on this list. Change the test_process.rb
to
the implementation shown below:

— vendor/rails/actionpack/lib/action_controller/test_process.rb
def html_document
HTML::Document.new(@response.body)
end

Let us know if that fixes the problem.

I tried this and it seems to work for some of the tests, but in turn,
produces a numerous amount of additional errors in other parts of the
testing.

I have to say that I am disappointed in this book. I think a good effort
was made in putting this out for programmers, but I find myself spending
more time trying to figure out what went wrong than actually learning. I
even copy over the folders from the source code I downloaded from the
authors and the code fails. Very frustrating.

I hit a wall with the book as well. Eventually I ditched the TDD and
just kept moving forward. There is some good stuff to learn about
implementing search, ajax, etc. This book converted me to migrations as
well. The unit tests are good reading to understand what is happening
under the hood but I’ll be damned if I wrote them after they started
failing with wierd configuration errors. I still read them though.

The chapter on forums is pretty good though I challenged myself to roll
my own forum and did it in less than 2 hours (and I’m a terrible
programmer!) Eventually you come to realize that this book is mainly
about TDD and integrating plugins. It does cover things that aren’t
widely explained like e-commerce and deployment. Just don’t get bogged
down if a test fails - I didn’t! Focus on the programming concepts.

Taylor S. wrote:

Just don’t get bogged down if a test fails - I didn’t! Focus on the programming concepts.

Glad somebody else has adopted this attitude. :wink:

BTW - I just visited the site for the book:
http://www.railsecommerce.com/

and lo and behold they’ve started a google group for the book:

http://groups.google.com/group/railsecommerce

Best,
Don C.

Secondbridge wrote:

BTW - I just visited the site for the book:
http://www.railsecommerce.com/

and lo and behold they’ve started a google group for the book:

http://groups.google.com/group/railsecommerce

Yup,

And we’re also not living in a cave, it’s just next to impossible to
keep up with the volume of this list. Hence the specific list for the
book.

//jarkko


Jarkko L.

http://www.railsecommerce.com
http://odesign.fi

Readers don’t really care if George is threatening you with offshoring
or if
he does not have money to hire programmers, they care only about getting
the
code work so that they can learn something from the book.

It is very annoying to read about irrelevant things about George The
Great
when the relevant instructions are missing. It would not hurt to repeat
the
instructions to get the code running. Sorry for the rant, but George
really
pisses me off.

Bala P. wrote:

One of the things that the book does not mention is that the fixtures that
you use must have proper data. Copy all the fixtures files from the
downloaded source and give it a shot. It may not solve all problems but
atleast we have exhausted all options.

Actually, on page 114:

“Therefore, we need to expand our … fixture files in test/fixtures.
You can download the files from the Source Code/Downloads section of
www.apress.com.”

There were just no idea to list all the fixtures in the book. So after
that point the book assumes you have the downloaded fixtures. Before
it, you should not need them if you have created the fixtures like told
in the book.

Best,
//jarkko


Jarkko L.

http://www.railsecommerce.com
http://odesign.fi