# Ruby on Rails & SQLite3

**URL:** <https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086>\
**Category:** Rails\
**Created:** [November 7, 2006, 12:59pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086 "2006-11-07T12:59:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 7, 2006, 12:59pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/1 "2006-11-07T12:59:31Z")

</div>

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](http://localhost:3000/recipe/new)

I’m getting the following 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”}

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

Thanks in advance.

Raj

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 7, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/2 "2006-11-07T21:22:03Z")

</div>

1. Did you migrate
2. Did you restart WEBrick
3. is SQLite3 on your path?
4. Did you do gem install sqlite3-ruby

Let me know and we can go from there.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 8, 2006, 7:29am UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/3 "2006-11-08T07:29:53Z")

</div>

Hi Brian,

1. Did you migrate  
No , i did not migrate

2. Did you restart WEBrick  
yes, Had restarted WEBrick after changing the config files.

3. is SQLite3 on your path?  
Yes, SQLite3 is set in my path.

4. Did you do gem install sqlite3-ruby  
Yes, i have used gem install sqlite3-ruby-1.1.0  
and have installed the latest version of mswin32.gem

What would the problem be.??

Raj

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 8, 2006, 1:54pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/4 "2006-11-08T13:54:59Z")

</div>

Did you try creating a new recipe via the console?

cd to the root of your rails application and enter:

ruby script/console

in the console enter

r = Receipe.new  
r.save

And check what happens.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 8, 2006, 4:01pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/5 "2006-11-08T16:01:27Z")

</div>

I haven’t developed anything on windows for a while but iirc you have to  
specify the full path to your db, i.e.

dbfile: c:/yourapp/db/test.db

I cannot remember if it’s forward of back slashes, you should try both

You may also want to look at this -  
[http://redhanded.hobix.com/cult/sqlite3Gem\_whySSensibilitiesRepack.html](http://redhanded.hobix.com/cult/sqlite3Gem_whySSensibilitiesRepack.html)

easiest option for windows by the look of things.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 8, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/6 "2006-11-08T18:39:54Z")

</div>

The full path is not required in windows.

dbfile: db/test.db

is fine.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 9, 2006, 12:42pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/7 "2006-11-09T12:42:20Z")

</div>

Hi Malmeida,

Tried

r = Receipe.new  
using ruby script/console.

Am getting the same error

ActiveRecord::StatementInvalid: ActiveRecord::StatementInvalid  
from  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_recor  
d/connection\_adapters/sqlite\_adapter.rb:259:in `table_structure' from C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_suppo rt/core_ext/object/misc.rb:23:in`returning’  
from  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_recor  
d/connection\_adapters/sqlite\_adapter.rb:258:in `table_structure' from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_recor d/connection_adapters/sqlite_adapter.rb:196:in`columns’  
from  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_recor  
d/base.rb:696:in `columns' from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_recor d/base.rb:1969:in`attributes\_from\_column\_definition’  
from  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_recor  
d/base.rb:1351:in `initialize_without_callbacks' from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_recor d/callbacks.rb:236:in`initialize’  
from (irb):1:in `new’  
from (irb):1  
Active Record::Statement Invalid

Been stuck with this for the past 1 week.  
Would be really happy if anybody could help me solve this problem 🙂

Raj

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 9, 2006, 4:21pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-sqlite3/75086/8 "2006-11-09T16:21:09Z")

</div>

What does your model look like?

You did not migrate, so did you even create a table Recipe in the  
database?  
What does your table structure look like? You can fire up sqlite and  
dump the table structure

> sqlite db/dev.db

> .dump

That should print out what your tables look like. It could be table  
name and your model names are not matching (Rails magically assumes  
pluralized table names, but the model names are singular, etc.), or you  
might not even have a Recipe table in your db.

Another question. Are you spelling Recipe or Receipe?! In the above  
posts, I see Receipe but should be Recipe.
