occasionally useful ruby, ubuntu, etc


Quick Start with Sequel 3 in Rails 3

This guide is using Rails 3.2.6 and Sequel 3.37.0. If you're using a different version, these instructions may not quite apply.

Edit: realized this morning the title was ambiguous, so I updated it to reflect the Sequel focus.

Here's the easiest way to get going with Sequel in Rails:

  1. Add sequel and talentbox-sequel-rails to your Gemfile.
  2. Replace require "rails/all" in your application.rb file with the expanded form, as given here.
  3. Comment out or remove any configuration lines in application.rb and environments/*.rb that start with config.active_record, or you'll get errors when your server starts up.
  4. That's it! You can run rails generate model foo just like you can with ActiveRecord, and it'll generate a migration and a model file for you.

Using BCrypt

Honestly, the directions at the official bcrypt-ruby site are pretty good and don't require much explanation. You don't need to require "bcrypt" in your model file(s), as it implies, but just uncomment the line mentioning bcrypt-ruby that you probably already have in your Gemfile, unless you deleted it or have an older version of Rails. You'll also want to add , :require => 'bcrypt' to the line to cause it to get loaded correctly. For reference, this looks like gem 'bcrypt-ruby', '~> 3.0.0', :require => 'bcrypt' on my machine.

Hope this helps someone. It's not that complicated, but having a step-by-step guide is always a Good Thing. Would have helped me anyway!

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.