Notes for myself on learning rails
I set up rails using:
http://rubyonrails.org/download
Everything below here deals with the Windows install – since Tomcat on linux is causing me problems, I’m using windows right now so I can switch between jsp/servlets/php/rails more easily.
After initial setup, I always received this error:
Could not find gem ‘sqlite3 (>= 0)’ in any of the gem sources listed in
your Gemfile.
Eventually Google gave me this solution, which is to specify WHICH sqlite3 gem to use:
gem ‘sqlite3-ruby’, ’1.3.2′, :require => ‘sqlite3′
After which, I ran bundle install and everything went fine.
This is in total contrast to trying to run rails using mysql – both version 1.8.7 and 1.9.2 seem to only want to use mysql2, even after specifying in the Gemfile and in config/database.yaml to use mysql. I would always get this:
Could not find gem ‘sqlite3 (>= 0)’ in any of the gem sources listed in
your Gemfile.
Eventually I worked around this by downloading an older version of the libmySQL.dll (when I find the link I’ll update this) and putting that directly into the Ruby/bin dir. Not a great workaround. An actual ‘fix’ for this seems to be described on this page:
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html – however, this solution is only for a full install of the mysql server on your machine. I use WAMP for PHP dev, so I decided rather than remembering to stop and start WAMP mysql ten times a day, I would just use this workaround:
First, install the DevKit from here:
http://rubyinstaller.org/downloads – make sure to read the docs first.
Then, update the Gemfile in your rails app:
gem ‘mysql2′, ’2.8.1′
Run bundle install.
run rake db:migrate (after rails generate to generate the models. More on this later.)
Following this tutorial:
http://ruby.railstutorial.org/chapters/beginning#top
Notes:
While using the github client for windows, always use git bash. Half of the time, commands work from the windows cmd prompt, but the other half they don’t.
ex: c:\Ruby\rails\first_app>git push origin master
error: src refspec master does not match any.
error: failed to push some refs to ‘git@github.com:jgbarr/first_app.git’
While using git bash remember to cd to the correct directory! After 1st setup (on windows 7), you’ll be in your home directory, where the .ssh dir was created.
Using the git client for windows was pretty painless, so long as I remembered to do things correctly. I ended up with this (github profile: http://github.com/jgbarr/):
https://github.com/jgbarr/first_app
Read More