SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,048
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    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.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I brought up the shovell prompt and the entered mysql5 -u root , but it said not recognized

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,048
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    It may be that you don't have mysql5 installed or maybe it's not configured correctly.

    Did you install MySQL as a gem?

    If you look in
    C:\[ruby install folder]\lib\ruby\gems\1.8\gems
    do you see a mysql folder?

  5. #5
    Team ********* Louis Simoneau's Avatar
    Join Date
    Sep 2009
    Location
    Melbourne, Australia
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The book is actually using SQLite, not MySQL.

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

  6. #6
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    Last edited by 4877; Oct 8, 2009 at 04:31. Reason: incomplete

  7. #7
    Team ********* Louis Simoneau's Avatar
    Join Date
    Sep 2009
    Location
    Melbourne, Australia
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    production:
    adapter: sqlite3
    database: db/production.sqlite3
    pool: 5
    timeout: 5000
    the ruby console does not allow pasting is that normal?

  9. #9
    Team ********* Louis Simoneau's Avatar
    Join Date
    Sep 2009
    Location
    Melbourne, Australia
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  10. #10
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  11. #11
    Team ********* Louis Simoneau's Avatar
    Join Date
    Sep 2009
    Location
    Melbourne, Australia
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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)

  12. #12
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    worked. but I had to delete the .sqlite file since it was empty. I moved on and found another puzzle but I will post another thread and see if someone else can answer it to give you a possible break


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •