This gem provides the railtie that allows sequel to hook into rails3 and thus behave like a rails framework component. Just like activerecord does in rails, sequel-rails uses the railtie API to hook into rails. The two are actually hooked into rails almost identically.
The code for this gem was initially taken from the excellent dm-rails project.
Using sequel with rails3 requires a couple minor changes.
First, add the following to your Gemfile:
… be sure to run “bundle install” if needed!
Secondly, you'll need to require “sequel-rails/railtie” in your config/application.rb file, and not require activerecord. The top of your config/application.rb will probably look something like:
# require 'rails/all' # Instead of 'rails/all', require these: require "action_controller/railtie" require "sequel/rails/railtie" require "action_mailer/railtie" require "action_view/railtie"
After those changes, you should be good to go!
Available sequel specific rake tasks
To get a list of all available rake tasks in your rails3 app, issue the usual
Once you do that, you will see the following rake tasks among others. These are the ones that sequel-rails added for us.
... vendor/bin/rake db:create # Create the database(s) defined in config/database.yml for the current Rails.env - also creates the test database(s) if Rails.env.development? vendor/bin/rake db:create:all # Create all the local databases defined in config/database.yml vendor/bin/rake db:drop # Drops the database(s) for the current Rails.env - also drops the test database(s) if Rails.env.development? vendor/bin/rake db:drop:all # Drop all the local databases defined in config/database.yml vendor/bin/rake db:migrate # Migrate the database to the latest version vendor/bin/rake db:migrate:down[version] # Migrate down using migrations vendor/bin/rake db:migrate:up[version] # Migrate up using migrations vendor/bin/rake db:seed # Load the seed data from db/seeds.rb vendor/bin/rake db:sessions:clear # Clear the sessions table for SequelStore vendor/bin/rake db:sessions:create # Creates the sessions table for SequelStore vendor/bin/rake db:setup # Create the database, load the schema, and initialize with the seed data ...
TODO (not necessarily in that order)
Publish SQL issued by sequel to rails subscribers
Note on Patches/Pull Requests
Fork the project.
Make your feature addition or bug fix.
Add tests for it so that future versions don't break it.
Commit, do not mess with rakefile, version, or history.
Send a pull request. Bonus points for topic branches.
Brasten Sager (brasten)
Copyright © 2010 The sequel-rails team. See LICENSE for details.