Sha256: cdf0eabc280102c64ab6324c8dbc66d2c53f0c7f851cdb7eb71bb2528be6f36c
Contents?: true
Size: 1.35 KB
Versions: 5
Compression:
Stored size: 1.35 KB
Contents
require 'rubygems' require 'camping' require 'camping/session' require 'bivouac' include Bivouac ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) ) task :environment do Camping.goes :BivouacSample # Load models from app/models files( 'models' ) { |file| require( file ) } # Load create files( '../db' ) { |file| require( file ) } # Load database schema from db/migrate files( '../db/migrate' ) { |file| require( file ) } require "#{ENV['BIVOUAC_ROOT']}/config/environment.rb" config = Bivouac::Environment.new( ) database_connection = config.environment.db if database_connection[:adapter] =~ /sqlite/ database_connection[:database] = ENV['BIVOUAC_ROOT'] + "/" + database_connection[:database] end BivouacSample::Models::Base.establish_connection database_connection end namespace :db do desc "Migrate the database through scripts in db/migrate." task :migrate => :environment do if BivouacSample.respond_to? :create BivouacSample.create else puts "Nothing to do!" end end desc "Clear the sessions table" namespace :sessions do task :clear => :environment do session_table = 'session' session_table = Inflector.pluralize(session_table) if ActiveRecord::Base.pluralize_table_names ActiveRecord::Base.connection.execute "DELETE FROM #{session_table}" end end end
Version data entries
5 entries across 5 versions & 1 rubygems