SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply Rails 2 - page 103

    Hi there,

    I am trying to work through this book as a complete novice so I hope someone can help. I'm at p103 and am trying to create the story.class but I get an error telling me that the table I created on the previous page is not there.

    I checked that it was created using the '.tables' cmd and got 'STORIES' but looks like the console can't find it... Error message below... have also checked that my database is in sqlite3... Please help



    C:\InstantRails\rails_apps\shovell>ruby script/console
    Loading development environment (Rails 2.0.2)
    >> class Story<ActiveRecord::Base; end
    => nil
    >> story = Story.new
    ActiveRecord::StatementInvalid: Could not find table 'stories'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/connection_adapters/sqlite3_adapter.rb:29:in `table_structure'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib
    /active_support/core_ext/object/misc.rb:28:in `returning'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/connection_adapters/sqlite_adapter.rb:189:in `columns'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/base.rb:1080:in `columns'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/base.rb:2363:in `attributes_from_column_definition_without_lock'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
    from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
    active_record/base.rb:1922:in `initialize'
    from (irb):2:in `new'
    from (irb):2
    >>

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2003
    Location
    Akron, OH, USA
    Posts
    102
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    This may be a silly question but...did you set up your database.yml??

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep all set up and checked!

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,161
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Hi JABlok, welcome to the forums,

    The book suggests that you copy/paste the code from the code archive after calling up the console by
    ....shovell>sqlite3 db/development.sqlite3

    The code in the archive file is
    Code:
    USE shovell_development;
    CREATE TABLE `stories` (
      `id` int(11) NOT NULL auto_increment,
      `name` varchar(255) default NULL,
      `link` varchar(255) default NULL,
      PRIMARY KEY (`id`)
    );
    But the code in the book is
    Code:
    CREATE TABLE stories (
     "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     "name" varchar(255) DEFAULT NULL,
     "link" varchar(255) DEFAULT NULL,
     "created_at" datetime DEFAULT NULL,
     "updated_at" datetime DEFAULT NULL
     );
    This has caused some problems. According to the errata page http://www.sitepoint.com/books/rails2/errata.php
    # p.102, 1st code listing

    The SQL code in the book is correct, the code in the code archive is incorrect.

  5. #5
    SitePoint Member
    Join Date
    May 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your response, I had picked that up and had it confirmed from other threads of yours in this forum but still have this problem... I check which version I had which was 2.3.2 so reinstalled 2.0.2 to match the book, re installed Gems, still have issues...

  6. #6
    SitePoint Member
    Join Date
    May 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, thank you for your responses... I re did everything and now seems to be working.

  7. #7
    SitePoint Member ryan0124's Avatar
    Join Date
    Mar 2007
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for sharing
    06.org, Corrected.com, FlipHome.com, Skirt.info
    www.TakeDomain.com
    Best Youtube Video Downloader


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
  •