Skip to content

Instantly share code, notes, and snippets.

Created October 16, 2011 14:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Rails 3.1 Template for DataMapper 1.2.0.rc2
# This needs to be called after one of the gemfile templates
apply ''
apply ''
inject_into_file 'app/controllers/application_controller.rb',
"require 'dm-rails/middleware/identity_map'\n",
:before => 'class ApplicationController'
inject_into_class 'app/controllers/application_controller.rb',
" use Rails::DataMapper::Middleware::IdentityMap\n"
say ''
say '---------------------------------------------------------------------------'
say "Edit your Gemfile (do not forget to run 'bundle install' after doing that)"
say "Some of the following commands assume that you passed the --binstubs option"
say "to bundle install. If you haven't done so, use 'bundle exec rake' where the"
say "examples below use './bin/rake'"
say '---------------------------------------------------------------------------'
say 'If you want to use rspec for testing, you first need to uncomment the line'
say "that declares it in the Gemfile. The you need to run 'bundle install' again"
say "Once that's done, you need to actually install it into your app and update"
say "your spec_helper as shown in the dm-rails README"
say '---------------------------------------------------------------------------'
say 'Install rspec (optional): rails g rspec:install'
say 'Have a look at the dm-rails README:'
say '---------------------------------------------------------------------------'
say 'Have a look at available rake tasks: ./bin/rake -T'
say 'Generate a simple scaffold: rails g scaffold Person name:string'
say 'Create, automigrate and seed the DB: ./bin/rake db:setup'
say 'Start the server: rails server'
say '---------------------------------------------------------------------------'
say 'After the sever booted, point your browser at http://localhost:3000/people'
say '---------------------------------------------------------------------------'
say ''
# workaround <<-GEMFILE wanting to
# execute the string subsitution
database = options[:database]
database = 'postgres' if database == 'postgresql'
database = 'sqlite' if database == 'sqlite3'
remove_file 'Gemfile'
create_file 'Gemfile' do
source :rubygems
RAILS_VERSION = '~> 3.1.1'
DM_VERSION = '~> 1.2.0.rc2'
gem 'tzinfo', '~> 0.3.30'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
gem 'railties', RAILS_VERSION, :require => 'rails'
gem 'dm-rails', '~> 1.2.0.rc2'
gem 'dm-#{database}-adapter', DM_VERSION
# You can use any of the other available database adapters.
# This is only a small excerpt of the list of all available adapters
# Have a look at
# for a rather complete list of available datamapper adapters and plugins
# gem 'dm-sqlite-adapter', DM_VERSION
# gem 'dm-mysql-adapter', DM_VERSION
# gem 'dm-postgres-adapter', DM_VERSION
# gem 'dm-oracle-adapter', DM_VERSION
# gem 'dm-sqlserver-adapter', DM_VERSION
gem 'data_mapper', DM_VERSION
gem 'dm-observer', DM_VERSION
group :development, :test do
# Uncomment this if you want to use rspec for testing your application
# gem 'rspec-rails', '~> 2.6.1'
# To get a detailed overview about what queries get issued and how long they take
# have a look at rails_metrics. Once you bundled it, you can run
# rails g rails_metrics Metric
# rake db:automigrate
# to generate a model that stores the metrics. You can access them by visiting
# /rails_metrics
# in your rails application.
# gem 'rails_metrics', '~> 0.1', :git => 'git://'
apply ''
apply ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment