The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

simply rails 2-page 102 unclear

I made it to page102 without a problem... now he has got me puzzled again. not sure what he saying to do at all. he wants me to open the SQLite console that he claims I invoked via the application directory. now, I do see the command he has there but he doesn't say where to put it, and if he is giving you the command why does he say download it from the the code archive. as you can see I don't have a clue and I did try to figure it out on my own. Can anybody help?

The chapter has a figure (#2?) that shows an example of what the console could look like (Mac?). In the CLI, from your app folder, in Windows it might look like

....shovell>

at the prompt, i.e. the ">" enter

>mysql5 -u root

if all goes well, you should then get the mysql prompt

mysql>

The file in the archives contains SQL syntax that can be used to create the database. It doesn't in itself create the database, you still need to enter it in one console or another, whatever you're using.

He's using the sqlite3 command to bring up the sqlite console loading in the development db (db/development.sqlite3). You just run that command from the application's directory (C:\shovell\ or whatever).

it worked, i got the nil, but when I tried to move on it said...statement invalid could not find table 'stories'. so I tried to create the table again and it seemed to work as stated after I pasted in the code and i ended up with ...> but it still said could not find table 'stories' when I put the next line in

Check your database.yml file to make sure rails knows where your database is, assuming your stories table was created correctly it still won't be found by the console script if you don't tell rails where to find your db.

I had checked the database.yml before and it seemed to be in order, here it is
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

Ok, you shouldn't be ending up with '...>' as your prompt after issuing the CREATE TABLE command in your sqlite3 prompt, that prompt means that the command isn't done (the base sqlite3 prompt is 'sqlite>')

Try this: open your sqlite db with the command line sqlite3 util from your shovell directory:

Code:

sqlite3 db/development.db

Now you should have the prompt 'sqlite>'. Then type the command:

Code:

.tables

and hit return. This command should list all the tables in that db, so if your stories table was created you should see 1 line saying "stories". If you don't then you need to retry the CREATE TABLE command. Make sure you type it EXACTLY as it appears in the book (maybe you're forgetting the semi-colon?) and hit return. Then exit sqlite3 by typing ".quit" and try your console again.

I seemed to make some progress. When I put in .tables in at the sqlite prompt the word stories appeared, but when I went back to the rails console and put in story = Story.new It still said it can't find the the table stories, how do you figure?

Oh, I made a mistake in my last post: I said to do "sqlite3 db/development.db" instead of "sqlite3 db/development.sqlite3", so your database might have the wrong name. Can you check in your "db" folder what files are in there?

If there's a file called development.db, you can rename it to development.sqlite3 and you should be back on track (it will now match up with the filename in your database.yml file)