Hello, fellow traveler. This project is very outdated nowadays (Dec 2013). Please checkout https://github.com/colszowka/rack-boilerplate for a more current approach to this
A basic skeleton for ActiveRecord-backed Ruby apps
http://blog.olszowka.de/2009/02/21/introducing-activerecord-skeleton/
- YAML database config
- Rake tasks for generating migrations and migrating the database
- Reasonable, Rails-style directory structure
- Ready to go with SQLite 3
- RACK_ENV-aware and thus ready to use with multiple environments with Sinatra or any other Rack-backed webapp framework
- Logging for ActiveRecord
- Get and extract tarball or git clone this repository
- Copy config/database.sample.yml to config/database.yml
- Create a migration with
rake generate:migration NAME=create_usersand add your code indb/migrate/001_create_users.rb rake migrate(if you stick to the default SQLite setup, the database for the current environment will be automatically created upon migration)- Create a model in lib/user.rb:
class User < ActiveRecord::Base; end; - Add application code in project root directory and
require 'init'in it
Example for usage with Sinatra
In your application file (say app.rb sitting in the project root), simply add require 'init' after require 'sinatra'.
A basic sinatra app.rb might look like following (assuming you’ve got the user model setup and migrated)
require ‘sinatra’
require ‘init’get ‘/’ do
User.all.map {|u| u.name}.to_sentence
end
activerecord-skeleton is Copyright © 2009 Christoph Olszowka, It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.