Subject: running the code
Posted By: ynkaa Post Date: 6/23/2008 12:57:42 PM
I know this is not a book for beginners, but can somebody please explain to me in simple steps how to run the code? I do not want to create my own application at this point, I want to see the code work and be able to modify it. Whatever I do I get the
undefined method `session=' for ActionController::Base:Class
message. Still, I am more interested in a step-by-step guide than just explaining what the message means.


Reply By: noelrap Reply Date: 6/23/2008 1:04:31 PM
I'm happy to help you, but I need a little more information.

Are you using the provided files, or typing text in from the book?  What are you trying to run, and could you post the error message in a little more detail.

Thanks,

Noel
Reply By: ynkaa Reply Date: 6/23/2008 1:22:16 PM
I downloaded the code and would like to run it. I have the latest stable versions of Rails and MySQL installed. I have written a few very simple Rails applications, but this is the first time I have tried to run something written by somebody else.

Could you try to tell me (I think more people would appreciate it) what are the basics steps to run it (I am using windows xp)?

If it is not enough then I will try to redo my actions and send you full output.

It is great you are answering so fast! Thanks!

Reply By: ynkaa Reply Date: 6/24/2008 12:57:34 PM
Somebody advised me to comment two lines in the environment.rb file
#  config.action_controller.session = { :Session_key => "_myapp_session",
#    :Secret => "some secret phrase" }
and I got the server running.

But when I try to display something, I get the message
Mysql::Error: #42S02Table 'soupsonline_development.recipes' doesn't exist: SHOW FIELDS FROM recipes

I created the 3 databases manually and granted the rights to the correct user. When I try to run rake db:migrate, I get

...

== CreateRecipes: migrating ===================================================
-- create_table(:recipes)
rake aborted!
undefined method `string' for #<ActiveRecord::ConnectionAdapters::TableDefinitio
n:0x48e791c>

(See full trace by running task with --trace)

Can you help me with this? Or if is too simple for this kind of forum just tell me...


Reply By: noelrap Reply Date: 6/24/2008 1:23:29 PM
It sounds like you don't have Rails 2.0 installed on your system. You might want to try a

sudo gem install rails

or

rake rails:freeze:edge

see http://p2p.wrox.com/topic.asp?TOPIC_ID=71100 for a little more info.

Noel
Reply By: ynkaa Reply Date: 6/26/2008 11:51:43 AM
I got it up and running. Here is what I had to do:

1. in environment.rb, change
RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION
to
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION

2. just in case, run
gem install -v 2.0.2 rails

3. in environment.rb, change
"some secret phrase" to a 30-character long string

4. adjust config/database.yml

5. THEN, finally, run rake db:migrate

6. copy canvass image files from their webpage (for some reason they were missing for chapter 1).

It is not THAT clear to start with, you know :)

It is working now, I wrote it for people like me who might find their way here someday.

Reply By: noelrap Reply Date: 6/30/2008 10:56:18 AM
This was sort of a tactical mistake I made -- the best instructions for getting Rails up and running are in chapter 2 under Subversion, but they are kind of buried, and there is no hint in Chapter 1 that you should look ahead. To make it worse, the change from subversion to Rails after the book was published makes some of the advice in chapter 2 about edge rails obsolete.

The best way to run rails is to have the version needed for that application in the vendor/rails directory.  If your gem rails is 2.0.2 or below, you can get to version 2.0.2 by going to the top of your Rails application and running

rake rails:freeze:edge REVISION=8441

Which is the subversion revision number of the 2.0.2 release.

If your gem rails is 2.1, then rake rails:freeze:edge downloads a mirror of the latest edge from git.  

If you have git on your system, then you can get Rails 2.0.2 in your vendor/rails with the following:

git clone git://github.com/rails/rails.git vendor/rails
cd vendor/rails
git branch v2.0.2

You might want to run the last command as git branch -b v2.0.2 -- this will clone the git repository where Rails is, and then switch you to the code as released for 2.0.2

If you don't have git on your system, Go to http://github.com/rails/rails/tree/master, select v2.0.2 from the "all tags" menu, then press download to get a tarball that you can extract to vendor/rails.

I still think this is kind of a mess, and that the tools for manipulating Rails from git are not fully developed yet.

(Also, starting from a new Rails project and adding the app files from the source file will work around some of the issues you had).

Sorry that this was less than clear.

Noel
Reply By: cgkrocks Reply Date: 8/14/2008 2:58:32 PM
This looks like it will be a real good book someday, but not this edition.  I've been working with rails for a few months and I need to learn 2.0, but I can't handle the non-functional code.

You need to get back into your source code and make it work for people who are trying to learn, not people who already know.  I'm returning the book.  The corrections that you suggest above are just too much and I can't spend another few days trying to get things to work.

Charles Kogge

Reply By: noelrap Reply Date: 8/14/2008 5:41:04 PM
I'm sorry you feel that way -- I hope you'll decide to stick with it, I think there's a lot of good stuff in the book if you can get started.

Might I make the following relatively simple suggestions to get started:

If you go to the web site http://github.com/rails/rails/tree/master you can download any version of Rails as a .zip file and unpack it in the vendor/rails directory.  Click on download -- the main download is the current edge rails, but clicking on any of the the other links will enable you to download that branch. The book was written against 2.0.2, but 2.0.3 should be safe, and almost everything should still work in 2.1

Another option is to walk through the steps in the book (in Chapters one and two) to create the application yourself, rather than using the entire application structure as is. You can then paste the code over, but in creating the app yourself, it will have the right version markers and environment for the version of gem rails on your system.  

Some of the other advice on this thread will cover other issues mostly caused by changes in Rails that came after production on the book completed.

I apologize for this -- it's a combination of a structural mistake on my part, as well as changes in the Rails distribution system that have made this more complex than I'd like.

Thanks,

Noel

Go to topic 73367

Return to index page 1