Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Port of ActiveRecord Rake Tasks for Sinatra

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 config
Octocat-spinner-32 tasks
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 sinatra_activerecord.rb
README
Sinatra ActiveRecord Tasks

Git URL: http://github.com/j4s0n/sinatra-activerecord-tasks/tree/master

This is a port of the ActiveRecord rake tasks that you can drop in to your sinatra application. By default, it requires the ActiveRecord gem.

After cloning, you need to copy everything on the cloned directory, to your sinatra's root directory. Be careful not to override your Rakefile (if you have any) else just copy what's packaged here.


After copying, then feel free to call `rake -T` 

and now use 'require sinatra_activerecord' to use activerecord on your sinatra app, like this.

require 'sinatra'
require 'sinatra_activerecord'

then connect to your db

configure  do
  ActiveRecord::Base.configurations = database_configuration
  ActiveRecord::Base.establish_connection(APP_ENV)
  ActiveRecord::Base.logger = Logger.new("activerecord.log") # Somehow you need logging right?
end

NOTE:
- Technically, RAILS_ROOT and RAILS_ENV are replaced as APP_ROOT and APP_ENV, so if you want to execute tasks on an  environment, just call rake db:migrate APP_ENV=production

- Somehow, i wasn't able to fix yet rake db:create / db:create:all on sqlite3 so feel free to patch in (or patch rails activerecord itself)

Something went wrong with that request. Please try again.