ruby and SQLite3

Discussion in 'Ruby' started by rajasekar98@gmail.com, Nov 7, 2006.

  1. Guest

    Hi,

    I'm just a beginner in Ruby.
    Have just installed Rails and Gems.
    I am using SQLite3 as the db.

    When going thro the "CookBook" tutorial.
    after creating the recipes table in the sqlite3 database.
    and changing the config file - database.yml as

    development:
    adapter: sqlite3
    dbfile: db/test.db

    test:
    adapter: sqlite3
    dbfile: db/test.db

    production:
    adapter: sqlite3
    dbfile: db/test.db

    and when trying to scaffold the recipe table from the browser using -
    http://localhost:3000/recipe/new

    I'm getting the following error

    <Error>
    ActiveRecord::StatementInvalid in RecipeController#new

    ActiveRecord::StatementInvalid
    RAILS_ROOT: ./script/../config/..

    Show session dump

    ---
    flash: !map:ActionController::Flash::FlashHash {}

    Response
    Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
    </error>

    Could anybody tell me, where i am going wrong??

    Thanks in advance.

    Raj
     
    , Nov 7, 2006
    #1
    1. Advertising

  2. wrote:
    > Hi,
    >
    > I'm just a beginner in Ruby.
    > Have just installed Rails and Gems.
    > I am using SQLite3 as the db.
    >
    > When going thro the "CookBook" tutorial.
    > after creating the recipes table in the sqlite3 database.
    > and changing the config file - database.yml as
    >

    ...

    >
    > I'm getting the following error
    >
    > <Error>
    > ActiveRecord::StatementInvalid in RecipeController#new
    >
    > ActiveRecord::StatementInvalid
    > RAILS_ROOT: ./script/../config/..
    >
    > Show session dump
    >
    > ---
    > flash: !map:ActionController::Flash::FlashHash {}
    >
    > Response
    > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
    > </error>
    >
    > Could anybody tell me, where i am going wrong??
    >
    > Thanks in advance.
    >


    May be this will help:

    http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3

    Using SQLite with Rails is a little bit tricky. But really just a little
    bit.

    Happy Rubying

    Stephan
     
    Stephan Kämper, Nov 7, 2006
    #2
    1. Advertising

  3. Guest

    Hi Stephan,

    Thanks for ur reply.

    Had checked out
    http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3
    Even downloaded the latest mswin32.gem
    and have done gem install sqlite-ruby-1.1.0.

    I am getting the same error after running the gem once again.

    ActiveRecord::StatementInvalid in RecipeController#new

    Any idea , what are the other reasons for such an error.

    Raj


    On Nov 8, 1:34 am, Stephan Kämper <>
    wrote:
    > wrote:
    > > Hi,

    >
    > > I'm just a beginner in Ruby.
    > > Have just installed Rails and Gems.
    > > I am using SQLite3 as the db.

    >
    > > When going thro the "CookBook" tutorial.
    > > after creating the recipes table in the sqlite3 database.
    > > and changing the config file - database.yml as..

    >
    >
    >
    >
    >
    > > I'm getting the following error

    >
    > > <Error>
    > > ActiveRecord::StatementInvalid in RecipeController#new

    >
    > > ActiveRecord::StatementInvalid
    > > RAILS_ROOT: ./script/../config/..

    >
    > > Show session dump

    >
    > > ---
    > > flash: !map:ActionController::Flash::FlashHash {}

    >
    > > Response
    > > Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
    > > </error>

    >
    > > Could anybody tell me, where i am going wrong??

    >
    > > Thanks in advance.May be this will help:

    >
    > http://code.whytheluckystiff.net/camping/wiki/BeAlertWhenOnSqlite3
    >
    > Using SQLite with Rails is a little bit tricky. But really just a little
    > bit.
    >
    > Happy Rubying
    >
    > Stephan
     
    , Nov 8, 2006
    #3
  4. wrote:
    > Hi Stephan,
    >
    > Any idea , what are the other reasons for such an error.


    Well, know that I've read your database.yaml it might also be due to
    some entries there:

    > development:
    > adapter: sqlite3
    > dbfile: db/test.db
    >
    > test:
    > adapter: sqlite3
    > dbfile: db/test.db
    >
    > production:
    > adapter: sqlite3
    > dbfile: db/test.db
    >


    First of all the databases for test, development and production should
    never be the same. Really never, or you may and will loose data.

    Second of all ... in my yaml file it actually says

    > test:
    > adapter: sqlite3
    > database: db/something_test.db3



    But then, the documentation I have only states dbfile as you wrote. So
    here maybe I'm plain wrong, although database works, too. I just checked it.

    Happy rubying

    Stephan
     
    Stephan Kämper, Nov 8, 2006
    #4
  5. Guest

    Hi Stephan,

    Thanks for ur reply.
    Really have got stuck in this problem for the last 1 week.

    Have changed the database name like something_test.db.
    But stil i am facing the same problem.

    Need a clarification.
    What is the need for having Production, Test and development attributes
    in the config file.
    What will happen if i comment the Production and the Development
    attributes in the config file.

    Raj


    On Nov 9, 1:10 am, Stephan Kämper <>
    wrote:
    > wrote:
    > > Hi Stephan,

    >
    > > Any idea , what are the other reasons for such an error.Well, know thatI've read your database.yaml it might also be due to

    > some entries there:
    >
    > > development:
    > > adapter: sqlite3
    > > dbfile: db/test.db

    >
    > > test:
    > > adapter: sqlite3
    > > dbfile: db/test.db

    >
    > > production:
    > > adapter: sqlite3
    > > dbfile: db/test.dbFirst of all the databases for test, development andproduction should

    > never be the same. Really never, or you may and will loose data.
    >
    > Second of all ... in my yaml file it actually says
    >
    > > test:
    > > adapter: sqlite3
    > > database: db/something_test.db3But then, the documentation I have only states dbfile as you wrote. So

    > here maybe I'm plain wrong, although database works, too. I just checked it.
    >
    > Happy rubying
    >
    > Stephan
     
    , Nov 9, 2006
    #5
  6. wrote:
    > Hi Stephan,
    >
    > Thanks for ur reply.
    > Really have got stuck in this problem for the last 1 week.
    >
    > Have changed the database name like something_test.db.
    > But stil i am facing the same problem.
    >
    > Need a clarification.
    > What is the need for having Production, Test and development attributes
    > in the config file.


    Well, if you use the same DB all over, you end up using you production
    database also for developing and testing. That's very, very bad, because
    you will delete important information from your production system sooner
    or later (I guess it'll be sooner rather than later).
    Apart form that there are a lot more good reasons to keep differentd
    things separate.

    > What will happen if i comment the Production and the Development
    > attributes in the config file.


    Well, you can't use these environments any longer. See your favourite
    Rails documentation for further reference.

    BTW. you might also try using the rails-mailing-list for Rails stuff.
    The folks over there are a lot more Rails-oriented than here on the Ruby
    list (resp. news group).

    Cheers

    Stephan
     
    Stephan Kämper, Nov 9, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harold Hausman

    Strangeness with ruby-web and sqlite3

    Harold Hausman, Jul 17, 2006, in forum: Ruby
    Replies:
    2
    Views:
    174
    Harold Hausman
    Jul 17, 2006
  2. Jos Backus

    ruby-DBI and SQLite3?

    Jos Backus, Jan 17, 2007, in forum: Ruby
    Replies:
    3
    Views:
    149
    Jos Backus
    Apr 4, 2007
  3. Jeffrey 'jf' Lim
    Replies:
    5
    Views:
    538
    Jeffrey 'jf' Lim
    Apr 9, 2007
  4. Manish Kalra
    Replies:
    2
    Views:
    113
    _-_ Daniel _-_
    Dec 2, 2008
  5. SunSw0rd
    Replies:
    4
    Views:
    289
    SunSw0rd
    Jul 2, 2009
Loading...

Share This Page