SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply Rails 2 page 103

    Hi guys I finally got down the sql database creation in Simply Rails 2. Now here is the problem when I started the rails portion. I type in the following:

    tom-dooleys-computer:~/desktop/build/shovell tomdooley$ ruby script/console
    Loading development environment (Rails 2.1.0)
    >> class Story < ActiveRecord::Base; end
    => nil
    >> story = Story.new
    ActiveRecord::StatementInvalid: Could not find table 'stories'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in `table_structure'
    from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/object/misc.rb:28:in `returning'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:189:in `columns'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1145:in `columns'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2598:in `attributes_from_column_definition_without_lock'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2126:in `initialize'
    from (irb):2:in `new'
    from (irb):2


    What do I need to do to correct my error?

  2. #2
    SitePoint Zealot daveporter's Avatar
    Join Date
    Mar 2002
    Location
    Perth, Western Australia
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi There,

    Well it says that stories does not exist...

    Can you check if it does or not ?

    cheers, Dave P

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am getting the same exact error message. Stories does exist. I can see it in PHPmyadmin

  4. #4
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,335
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    What is in 'development' in your config/database.yml file?
    You may not be connecting to the database (or to the correct one).
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  5. #5
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this might be my problem.

    /opt/local/lib/ruby/gems/

    The path it needs to pull from is /usr/local/bin

    How can I get ride of the /opt/local/lib/ruby/gems path?

  6. #6
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It says sqlite3 and that is what I have installed. I also have mySql intalled too. I know mysql is in the opt/local/bin folder. Following Simply Rails 2 book I created a path ~/.profile that has a path of usr/local/bin. Maybe that is where my sqlite3 database is at. What can I do to correct this?

  7. #7
    SitePoint Member eman8ions's Avatar
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey C_Programmer0101 are you still stuck here? I am (see my pg 103 thread). It's not looking like there is much help for this here if your last post was ten days ago and still no response

  8. #8
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having this exact same problem...I have a table called stories in my development.sqlite file...my database.yml file is pointing to the correct place...downgraded sqlite to 1.2.1...I'm out of ideas

    *edit* well I'm an idiot...I left out the 3 in "sqlite3 db/development.sqlite3"...make sure you guys didn't do the same thing...I guess when it says it can't find the table...it means it really can't find the table
    Last edited by PointlesS76; Jul 10, 2008 at 21:56.

  9. #9
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you have already done this portion I assume "gem install sqlite3-ruby -v=1.2.1", I believe that one of both of the below is your problem:

    1. You may have a typo in your file that has caused this problem for me before.
    2. Copy and paste the file from the sample code into your directory db.
    3. The sample code does not work for me...Copy the code exactly from the book using a text editor and save it (double check all typing).

    Post your code in the forums if you are still having problems or use pastie.org. One you paste your code copy/paste the code url in the forums.

  10. #10
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    This problem has been quite frustrating. I have tried to look up the directories in the error and it appears that they don't all exist, what file routes this? Anyone know how to reroute rails to use the right path? Thanks for the help everyone.

    >> story = Story.new
    NameError: uninitialized constant ActiveRecord::Base::SQLite3
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:492:in `const_missing'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `sqlite3_connection'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in `connection='
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:in `retrieve_connection'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1145:in `columns'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2598:in `attributes_from_column_definition_without_lock'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2126:in `initialize'
    from (irb):2

  11. #11
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Snizneth I have not seen that error before but it must be the same as the common error we all been having. Paste up the code you have for your stories table.

    Also, did you try installing in your "/desktop/build/sqlite-3.5.4" the following:

    sudo gem install sqlite3-ruby -v=1.2.1

  12. #12
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I'm stuck a the same point, but seems connection to ActiveRecord is the problem - my app is sitting on the WebServer (OS 10.4) as my home folder in encrypted, could this be the problem?

    Code:
    ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:265:in `retrieve_connection'
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1145:in `columns'
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2598:in `attributes_from_column_definition_without_lock'
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2126:in `initialize'
            from (irb):5:in `new'
            from (irb):5
    Thanks for any help!!

  13. #13
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to modify your database.yml file and then get out of ruby and then come back to console

    ruby script/console

    and run the following commands again

    class Story < ActiveRecord::Base; end

    story = Story.new

    in my case i have reached there and i also have the database's created and the `stories` table inside all the databases because i am a starter at this, even then when i run the following inside the console.

    story = Story.new

    i get an error saying, cannot find the stories table there must be some reason why this is happening, has any one got a guess
    @deel $hahid


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
  •