views:

317

answers:

2

I am very new to RoR... I installed Ruby and installed its gems...

then downloaded and installed MySql...

created my first directory demo.

then started the server using ruby script/server

entered the http://localhost:3000 url in the browser and get a "welcome aboard" page..all is well till now...

now I create a controller using ruby script/generate controller Say

the controller is created and it looks like this

class SayController < ApplicationController
 def hello

 end
end

I then create a view document hello.html.erb which looks like this..

<html>
<body>
    <h1>Hello World!!!</h1>
</body>
</html>

now I enter the url http://localhost:3000/say/hello in the browser and I get the following error

This application failed to start because sqlite3.dll was not found. Re-installing the application may fix this problem. and the browser shows a default error page

I did a bit of Googling and tried the following..

1.gem install sqlite-ruby

2.gem install sqlite3-ruby

the first returned a success message....the second initially gives a success message and then floods me with no definition errors.

I have not even started using models...why is it even throwing exceptions in sqlite..?! am totally confused and lost here since it is my first try with RoR...

thanks in advance...

A: 

found a solution...don't know if it is a hack or workaround...but it works...i made a copy of the sqlite3.dll and pasted it in ruby/bin floder and it works.!!

but i would like to know if this is the real solution...

ZX12R
It's good enough - you need the DLL somewhere on your PATH. ruby/bin is already there, which is why it works.
Mike Woodhouse
yes i agree... nate's response was useful...it is better to configure your app for the database of your choice rather than do workarounds...
ZX12R
+1  A: 

sqlite3 has been the default database since Rails 2.0.2 - previously it was MySQL. Database configuration is found in config/database.yml and you can change it if you want.

Even with no models, rails attempts to make sure the actual DBMS specified in database.yml is there for use.

The gems you installed are "drivers" to let you talk to the database through ruby (similar to JDBC drivers in Java or an ADO.NET driver for .NET) - not the actual DBMS. (sqlite3-ruby is the right one - I'm not sure why it displays all those "no definition for..." lines - it does for me too, but it works. Perhaps someone else knows why...)

The .dll is the DBMS. SQLite3 is a very lightweight database - dropping the .dll in the path is really all you need to do. Placing it in the ruby/bin directory is a common practice for development machines.

Nate
thanks...was really useful... :) but how do you change the default database..i tried fiddling with database.yml...but have no idea how to do it..
ZX12R
Here's a link showing how to specify MySQL from the RoR Wiki - http://wiki.rubyonrails.org/database-support/mysql
Nate
Thanks, I am having the same problem, except that sqlite3's dll *is* in my ruby\bin and it's still telling me it can't find it. Any other thoughts?
Paul
@Paul - 1.) make sure ruby\bin is on the %PATH% (it should be, if Ruby runs - you may have multiple installs though...) 2.) Corrupted sqlite3 dll? Try to re-download and re-install? 3.) Wrong file/version? Make sure you're getting the sqlitedll-3_6_23.zip file (or newer version) from the "Precompiled Binaries for Windows" section of the Sqlite3 site.
Nate
1) done and correct; 2) Nope, re-installed a couple times; the error is on the driver anyway not the sqlite3 dll; 3) Yes, 3_6_23.zip is the one I got.
Paul
@Paul - I was just looking back over this post and had a thought - are you trying this in ruby 1.9 or 1.8? I seem to recall another developer on my project having issues like this when they were trying to use ruby 1.9.
Nate
@Nate - yep, 1.9. I ended up just using MySQL instead, but it'd still be nice to know why this ain't working.
Paul
@Paul - there's some discussion on what's not / was not working here - http://isitruby19.com/sqlite3-ruby I just tried ruby 1.9.1, sqlite 3.6.23, and sqlite3-ruby 1.2.5 and it worked for me... I got a Rails app with 1 model with 1 string value to work backed by sqlite3. So maybe finally all the kinks are out...
Nate
Sweet, thanks, I'll try that out tomorrow.
Paul