by Ryan Walker

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

First version of Incentimove.com is simple:

  • / home page explaining concept

  • /register register before you move

    • sends notification email to site owner
    • sends confirmation email to registrant
    • saves to database
  • /claim after you move, claim your reward

    • sends notification email to site owner
    • sends confirmation email to claimant
    • saves to database
  • /refer know someone moving? refer to us and get $25

    • sends notification email to site owner
    • sends confirmation email to referrer
    • saves to database

MainController

delete /public/index.html

added to routes

root :to => "main#index"

let’s try out new rails generators

rails generate controller Main index

reloading http://localhost:3000/ shows Main#index Find me in app/views/main/index.html.erb - so generator worked.

Testing

it generated some tests, let’s see if controller test works… I tried installing ZenTest to try + get autotest up and running, but furthest I got was an ugly error:

dyld: lazy symbol binding failed: Symbol not found: _rb_str_new_cstr
  Referenced from: /Users/ryanwalker/.rvm/gems/ruby-1.9.2-head@rails3/gems/sys-uname-0.8.4/lib/sys/uname.bundle
  Expected in: flat namespace
dyld: Symbol not found: _rb_str_new_cstr
  Referenced from: /Users/ryanwalker/.rvm/gems/ruby-1.9.2-head@rails3/gems/sys-uname-0.8.4/lib/sys/uname.bundle
  Expected in: flat namespace
Trace/BPT trap

rake gives me

Errors running test:units, test:functionals, test:integration!

rake test:functionals gives me

rake aborted!
Don't know how to build task 'db:test:prepare'

If I modify the first line of test\functional\main_controller_test.rb to

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

then I can type ruby test/functional/main_controller_test.rb and I get

Finished in 0.046906 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips

Not ideal, but good enough for now—moving along…

Building out the site

I was able to get Compass 0.10.0.rc1 to install and run with

gem install compass --pre
rake rails:template LOCATION=http://compass-style.org/rails/installer

And I built out part of the homepage. Then I got sleepy again…