by Ryan Walker

Building an app with Rails 3 and MongoDB (part 1)

I built a website for my son this weekend, now I have to get the site for my brother done. It’s fairly simple and I’ve been procrastinating, so let’s make it fun. Rails 3 + MongoDB should do the trick to get my interest up.

I’ll keep Maxim Chernyak’s Rails 3 Reading Material page handy for reference.

Here we go…

Setup

Got environment setup using RVM

Created new private repository on github

Pulled down a starting point app

rvm use 1.9.2@rails3
cd Documents/projects
git clone http://github.com/banker/mongodb-rails3-sample incentimove
cd incentimove
rm -rf .git
git init
git commit -am 'first commit'
git remote add origin git@github.com:ryw/incentimove.git
git push origin master

See if app will startup:

rails server

Nope. Missing mongo gem

gem install mongo

Try again. Nope. Need to update Gemfile from:

gem "rails", "3.0.0.beta"

to

gem "rails", "3.0.0.beta2"

and install other bundled gems - whoops…

bundle install

try again… I get the rescue in get: protected method setup called for #<TZInfo::DataTimezone:0x000001015f85c8> (TZInfo::InvalidTimezoneIdentifier) error that others report in the beta 2 annoucement comments.

solution is to get onto edge ruby (ah… fond memories of developing using edge rails before rails 2) should be easier this time around…

rvm install 1.9.2-head

but it fails…

Error running 'make ', please check /Users/ryanwalker/.rvm/log/ruby-1.9.2-head/make*.log
There has been an error while running make. Aborting the installation.

the log

Mark Turner suggests running rvm install 1.9.2-head -C --enable-shared,--with-readline-dir=/opt/local,--build=x86_64-apple-darwin10 but it doesn’t help, but I remember that I haven’t upgrade macports in a long time so:

port upgrade outdated

55 minutes later…

rvm install 1.9.2-head -C --enable-shared,--with-readline-dir=/opt/local,--build=x86_64-apple-darwin10
rvm --create use 1.9.2-head@rails3
curl -L http://rvm.beginrescueend.com/gemsets/rails3b2.gems -o rails3.gems
rvm gemset import rails3.gems
gem install mongo
bundle update
rails server

Welcome aboard You’re riding Ruby on Rails!

It’s late - to be continued.