Skip to content

Cory Foy

Organizational agility through intersecting business and technology

Menu
  • FASTER Fridays
  • Mapping Mondays
  • Player Embed
  • Search Videos
  • User Dashboard
  • User Videos
  • Video Category
  • Video Form
  • Video Tag
Menu

Rails 2.0 apps without a database

Posted on July 18, 2008 by Cory Foy

If you are interested in spinning up a Rails app without a database, it is a little trickier in 2.0 than in previous versions. Do the following:


rails nodbspike
script/generate controller hello

This sets up a basic Rails app with a controller. Modify app/controllers/hello_controller.rb to include the following:


def index
  render :text => "Hello, world!"
end

You now have a basic controller set up. Let’s tell Rails not to use ActiveRecord. We do that by opening up config/environment.rb and adding the following line:

config.frameworks -= [ :active_record ]

So far, this is how you’d do this in Rails 1.x. However, in 2.0 they introduced a new file which will also try to use ActiveRecord. So open up the config/initializers/new_rails_defaults.rb file and comment out the two ActiveRecord lines.

You should now be able to fire up script/server, browse to http://localhost:3000/hello and code away!

1 thought on “Rails 2.0 apps without a database”

  1. robvs says:
    January 10, 2009 at 1:58 pm

    Thanks a bunch. Clear, concise, and it’s working for me.

Comments are closed.

© 2025 Cory Foy | Powered by Superbs Personal Blog theme