I’m working on both learning authlogic and Rails 3. The process here works (given the Rails 3.0.0.beta1 gem) for me. There is a list of the many resources I complied this from at the bottom of the document.
Travelers beware: this is incomplete, and possibly even wrong. But between the stuff about scaffolding and binary logic’s example app you should be able to get off your feet.
We assume Rails 3 is installed. We will create a rails app as usual.
rails authtest cd authest rails g scaffold post title:string body:text rails g scaffold user username:string fullname:string is_admin:boolean
We need to install from source, because of the latest Authlogic gem’s current incompatibility with Rails 3.
# ./Gemfile # ... gem "authlogic", :git => "git://github.com/binarylogic/authlogic.git"
Now, let bundle do its work
bundle install bundle pack
Create session, and prepare the user class
rails g migration AddAuthToUser crypted_password:string password_salt:string persistence_token:string rails g scaffold user_session --migration false --parent=Authlogic::Session::Base
h
# app/controllers/application.rb class ApplicationController < ActionController::Base filter_parameter_logging :password, :password_confirmation helper_method :current_user_session, :current_user private def current_user_session return @current_user_session if defined?(@current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined?(@current_user) @current_user = current_user_session && current_user_session.user end end