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"
After those changes, you should be good to go!
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 ...
There are bound to be a lot, but I'm not yet sure what they are
Publish SQL issued by sequel to rails subscribers
The dm-rails team wrote most of this code, I just sequel-ized it.
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so I don't break it in a future version unintentionally.
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
Send me a pull request. Bonus points for topic branches.
Brasten Sager (brasten)
Jonathan Tron (JonathanTron)
Improvements has been made by those awesome contributors:
Benjamin Atkin (benatkin)
Gabor Ratky (rgabo)
Joshua Hansen (binarypaladin)
Copyright © 2010 The sequel-rails team. See LICENSE for details.