SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member eman8ions's Avatar
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pg 103 - stuck - Simply Rails 2

    book says
    Code:
    From the Rails console, letís create this Story class, and an instance of the class 
    called story, by entering these commands: 
    
    
    >> class Story < ActiveRecord::Base; end
     
    => nil
     
    >> story = Story.new
     
    => #<Story id: nil, name: nil, url: nil, created_at: nil,
     
     updated_at: nil>
     
    >> story.class
     
    => Story(id: integer, name: string, link: string,
     
     created_at: datetime, updated_at: datetime)
    When I get to story = Story.new this is my result:

    Code:
    Loading development environment (Rails 2.1.0)
    >> class Story < ActiveRecord::Base; end
    => nil
    >> story = Story.new
    MissingSourceFile: no such file to load -- sqlite3/database
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require'
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2/lib/sqlite3.rb:1
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require'
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/requires.rb:7:in `require_library_or_gem'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
            from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem'
            from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:10: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 `send'
            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:in `new'
            from (irb):2>>
    Any help is appreciated!

    Just prior, I was in the Shovell dir and created the development.sqlite3 database. The the book says "now change to your shovell directory and start ruby console" - this is where I'm wondering... what do you mean 'change'... I was already in there for your previous instruction but maybe I'm misunderstanding something.

  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,

    Change means to 'move' into that directory.
    ( e.g. if you are on Windows used 'cd shovell' )

    But you are right, you mentioned you are in the shovell directory so that is fine. And in fact the rails script/console won't work unless you are in the shovell directory.

    Not sure why you are getting the results you are showing I'm afraid.

    But I would double check that your sqlite table has been created - that seems to be the thing.

    Check inside shovell/db and see if the database exists first. If it does then open it and see if the stories table exists. If not that is your problem!

    BTW: I've pasted below an earlier suggestion re a useful tool to view/edit sqlite databases/tables:


    >>>>>> Quote
    Hi Everyone,

    Just read a few posts with sqlite issues & thought I would offer a suggestion.

    There is an excellent Firefox add on ( as a Firefox extension) called Sqlite-Manager.

    And yes it works with the new ver 3.0 of Firefox!

    It is small, intuitive and easy to install.

    Get it here:
    http://code.google.com/p/sqlite-manager/

    HTH - Dave Porter

    p.s. Just added this addendum - this does not replace the requirement to install sqlite - it just makes manual changes easier...
    <<<<<< End quote

    HTH - Dave Porter

  3. #3
    SitePoint Member eman8ions's Avatar
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks daveporter, and I haven't used the tool you mentioned yet, but I did look in the db folder and my dev db is in there. I clicked to open it in TextMate on my macbook and it looks to me like the tables were created correctly... soo..... hmmm....

    edit: I installed the Firefox add-on and can confirm again that yes the stories table was created properly.

    Still the same problem
    Last edited by eman8ions; Jun 30, 2008 at 08:08. Reason: update

  4. #4
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    I was having the same problem you are on page 103, but I stumbled across a solution when I googled "no such file to load -- sqlite3/database" and found a post from groups.google.ca

    I had the 1.2.2 version of sqlite3-ruby. Following instructions from the post, I did:

    gem uninstall sqlite3-ruby
    and then
    gem install sqlite3-ruby -v=1.2.1

    (I use a Mac and had to preface both commands with "sudo")

    After that, I was able to type "story = Story.new" without an error.

    Hope That helps.

  5. #5
    SitePoint Member eman8ions's Avatar
    Join Date
    Aug 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    omg it worked. Thank you. Perhaps something for the errata page here, though I'm not exactly sure what. Makes no sense to me that a small version difference would screw the whole thing.

    thanks again Mark Y

    btw I'm on a mac too and will try to assist if you run into any probs too.

  6. #6
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for my late reply. I have been heavily in a project. I have learned that there is a gem missing when errrors like that occur. It looks like this needs to be installed. "gem_original_require"

  7. #7
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a way to quickly check all gems installed on the server?

    ~r
    Founder,
    Optimimo.com - Mobile Usability Testing
    PilotOutlook.com - Pilot training
    SocialAppsHQ.com - Social Media Marketing

  8. #8
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To see all the gems packaged on a server you will have to unpackage the gems. I do not have a instructions on how to do that but I believe you would unpackage them in your vendor/gems folder. That way if you had a project on the server that you want to port to another machine all the necessary gems are unpackaged in your project and you will not have to worry about looking to install the proper gems.

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajatgarg View Post
    Is there a way to quickly check all gems installed on the server?

    ~r
    >> gem list

  10. #10
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Reply to #4 - Mark Y.

    thank you for posting this! Your solution worked perfectly for the problem I was having.
    VJenner


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
  •