SQLite for Rails

So, all the cool kids say I should install SQLite for quick and easy DB development work. I’m not one to argue. I don’t know how this will work when I move forward. I’ve only used MySQL on Dreamhost and I assume that I will fit this app to use that at some point. My guess is that SQLite is just going to be for proof of concept type development work and that RoR will have some way of easily swapping DB connections without much issue.

First step: download


I’m on a Windows 7 64 bit machine so I grab sqlite-dll-win64-x64-3090200.zip.

That gives me the files sqlite3.dll and sqlite3.def. The Internet tells me that I want to put those in my Ruby bin directory. I copy them to “C:\Ruby193\bin”.

There is also a command-line shell program available on the SQLite site that will come in handy. I grab sqlite-shell-win32-x86-3090200.zip, unzip it and throw the exe into my bin directory as well.

Once I have those files, I can check things back in my Ruby console:

C:\Users\peter>sqlite3 -version
3.9.2 2015-11-02 18:31:45

Now I need to tell Ruby about it:

C:\Users\peter>gem install sqlite3
Fetching: sqlite3-1.3.11-x86-mingw32.gem (100%)
Successfully installed sqlite3-1.3.11-x86-mingw32
1 gem installed
Installing ri documentation for sqlite3-1.3.11-x86-mingw32…
Installing RDoc documentation for sqlite3-1.3.11-x86-mingw32…

I think this is now everything I need to get started.


Installing Ruby on Windows

To match my development environment to Dreamhost, I’m looking for Ruby 1.8.7 and Rails 3.0.3.

The current version of Ruby, as listed on https://www.ruby-lang.org, is Ruby 2.2.3.

There is a Ruby installer for Windows available via http://rubyinstaller.org/downloads/. The closest version available for the installer is Ruby 1.9.3-p551. Hopefully this is close enough to Dreamhost’s 1.8.7. I’m not planning on doing anything fancy at the moment so I can’t see a few dots difference in versions numbers to be all that important. I could check the release notes but I’m lazy busy.

I run the RubyInstaller and point it to C:\Ruby193 for my path. I check “Add Ruby Executables to your PATH”. Easy enough. Thanks, RubyInstaller.

There is now a Start->Ruby 1.9.3-p551 folder in my Start menu and a Start Command Prompt with Ruby shortcut beneath that.

C:\Users\peter>ruby -v
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]

So far, so good. Check the gem version:

C:\Users\peter>gem -v

Ok, I don’t know if that’s what I want but I know I need gem to install Rails and it seems to be working so far. The next step would be to try:

gem install rails

This would install the latest version of Rails but I want 3.0.3. From looking around at documentation, it looks like I can add a version flag on to the end to get a specific version:

C:\Users\peter>gem install rails -v 3.0.3
Fetching: activesupport-3.0.3.gem (100%)
Fetching: builder-2.1.2.gem (100%)
Fetching: i18n-0.7.0.gem (100%)
Fetching: activemodel-3.0.3.gem (100%)
Fetching: rack-1.2.8.gem (100%)
Fetching: rack-test-0.5.7.gem (100%)
Fetching: rack-mount-0.6.14.gem (100%)
Fetching: tzinfo-0.3.45.gem (100%)
Fetching: abstract-1.0.0.gem (100%)
Fetching: erubis-2.6.6.gem (100%)
Fetching: actionpack-3.0.3.gem (100%)
Fetching: arel-2.0.10.gem (100%)
Fetching: activerecord-3.0.3.gem (100%)
Fetching: activeresource-3.0.3.gem (100%)
Fetching: mime-types-1.25.1.gem (100%)
Fetching: polyglot-0.3.5.gem (100%)
Fetching: treetop-1.4.15.gem (100%)
Fetching: mail-2.2.20.gem (100%)
Fetching: actionmailer-3.0.3.gem (100%)
Fetching: thor-0.14.6.gem (100%)
Fetching: railties-3.0.3.gem (100%)
Fetching: bundler-1.10.6.gem (100%)
Fetching: rails-3.0.3.gem (100%)
Successfully installed activesupport-3.0.3
Successfully installed builder-2.1.2
Successfully installed i18n-0.7.0
Successfully installed activemodel-3.0.3
Successfully installed rack-1.2.8
Successfully installed rack-test-0.5.7
Successfully installed rack-mount-0.6.14
Successfully installed tzinfo-0.3.45
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.3
Successfully installed arel-2.0.10
Successfully installed activerecord-3.0.3
Successfully installed activeresource-3.0.3
Successfully installed mime-types-1.25.1
Successfully installed polyglot-0.3.5
Successfully installed treetop-1.4.15
Successfully installed mail-2.2.20
Successfully installed actionmailer-3.0.3
Successfully installed thor-0.14.6
Successfully installed railties-3.0.3
Successfully installed bundler-1.10.6
Successfully installed rails-3.0.3
23 gems installed

Looks promising.

Installing ri documentation for activesupport-3.0.3…
Installing ri documentation for builder-2.1.2…
Installing ri documentation for i18n-0.7.0…
Installing ri documentation for activemodel-3.0.3…
Installing ri documentation for rack-1.2.8…
Installing ri documentation for rack-test-0.5.7…
Installing ri documentation for rack-mount-0.6.14…
Installing ri documentation for tzinfo-0.3.45…
Installing ri documentation for abstract-1.0.0…
Installing ri documentation for erubis-2.6.6…
Installing ri documentation for actionpack-3.0.3…
Installing ri documentation for arel-2.0.10…
Installing ri documentation for activerecord-3.0.3…
ERROR: While generating documentation for activerecord-3.0.3
… MESSAGE: Invalid argument – ./<
… RDOC args: –ri –op C:/Ruby193/lib/ruby/gems/1.9.1/doc/activerecord-3.0.3/r
i –main README.rdoc lib README.rdoc –title activerecord-3.0.3 Documentation —

Is that bad? I don’t know. It’s for documentation. Who needs documentation anyway? I’m going to ignore it unless I find I need to do something about it later.

C:\Users\peter>rails -v
Rails 3.0.3

I guess that worked.

Ruby on Dreamhost

I have a shared hosting account on Dreamhost and that has pretty much limited me to PHP development for my side projects. However, they do support RoR and since Dreamhost is cheap, it’s a perfect place to get started.

I don’t want to jump into the latest version of Ruby or Rails. If a low budget radio station wants to use this code as a basis for their own site, they are going to face the same version restrictions as I have on Dreamhost.

What version of Ruby is Dreamhost running? http://wiki.dreamhost.com/index.php/Ruby_on_Rails lists some info but warns that it may be out of date.

To check right from the source, I SSH to the server to check the versions. I’m on a Windows machine so I use Cygwin as my SSH client. https://www.cygwin.com/

ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

rails -v
Rails 3.0.3




Learning Ruby on Rails

I’ve been putting off learning Ruby on Rails for a few years now. Mostly for lack of a reason. I work in .Net or Java for my day job and, even though I have played with Ruby, I haven’t had the chance to flesh out a Rails site.

I’ve worked with a few community radio stations and there is always a need for a dynamic website to hold the schedule, list of DJs, playlists, etc. I though this would be a good project to work on and make available to anyone that found it useful.