-
-
Save pasviegas/270200 to your computer and use it in GitHub Desktop.
working mongomapper rails template (jquery, cancan)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mongo_template.rb | |
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842) | |
# | |
# To use: | |
# rails project_name -m http://gist.github.com/270200.txt | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
# using jquery too | |
run "rm public/javascripts/controls.js" | |
run "rm public/javascripts/dragdrop.js" | |
run "rm public/javascripts/effects.js" | |
run "rm public/javascripts/prototype.js" | |
# MongoDB FTW! | |
db_name = ask('What should I call the database? ') | |
initializer 'database.rb', <<-CODE | |
MongoMapper.database = '#{db_name}-#{Rails.env}' | |
if defined?(PhusionPassenger) | |
PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
MongoMapper.database.connect_to_master if forked | |
end | |
end | |
CODE | |
file 'config/database.yml', <<-CODE | |
# Using MongoDB | |
CODE | |
# Don't need ActiveRecord | |
environment 'config.frameworks -= [:active_record]' | |
# MongoMapper | |
gem 'mongo_mapper' | |
# Testing Helper | |
file 'test/test_helper.rb', <<-CODE | |
ENV['RAILS_ENV'] = 'test' | |
require File.expand_path(File.dirname(__FILE__) + '/../config/environment') | |
require 'test_help' | |
require 'shoulda' | |
require 'mocha' | |
require 'factory_girl' | |
class ActiveSupport::TestCase | |
# Drop all columns after each test case. | |
def teardown | |
MongoMapper.database.collections.each do |coll| | |
coll.remove | |
end | |
end | |
# Make sure that each test case has a teardown | |
# method to clear the db after each test. | |
def inherited(base) | |
base.define_method teardown do | |
super | |
end | |
end | |
end | |
CODE | |
# Testing tools | |
gem 'redgreen' | |
gem 'shoulda' | |
gem 'factory_girl' | |
gem 'mocha' | |
#simple authorization | |
gem 'cancan' | |
# Gem management | |
rake 'gems:install' | |
rake 'gems:unpack' | |
rake 'rails:freeze:gems' | |
# source control | |
file '.gitignore', <<-FILES | |
.DS_Store | |
**/.DS_Store | |
log/* | |
tmp/* | |
tmp/**/* | |
config/database.yml | |
coverage/* | |
coverage/**/* | |
FILES | |
git :init | |
git :add => '.' | |
git :commit => '-a -m "Initial commit"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment