Posts Tagged ‘rails’

undefined method `use_transactional_fixtures=’ for Test::Unit::TestCase:Class

// April 17th, 2009 // 2 Comments » // Blog

If you have upgraded to Rails 2.3 and come across this error:
undefined method `use_transactional_fixtures=’ for Test::Unit::TestCase:Class

It probably means you have tests that were generated in an older version of Rails. Just open up test/test_helper.rb and change this:


class Test::Unit::TestCase

To this:


class ActiveSupport::TestCase

Voila!

Ruby on Rails HTTP Basic Auth with LDAP

// December 8th, 2008 // 8 Comments » // Blog

My friend Fred has a nifty tip over on his Binary Fever blog about Ruby on Rails LDAP authentication using HTTP Basic Auth. I took what he had done and made a few minor improvements:


# mygeneric_controller.rb
LDAPBASE = ‘, ou=active, ou=employees, ou=people, o=host.com’
before_filter :authenticate

protected

def authenticate
  authenticate_or_request_with_http_basic('LDAP Login') do |username, password|
   ldap = Net::LDAP.new :host => ‘ldap.host.com’, :base => LDAPBASE
   ldap.auth ‘uid=’ + username + LDAPBASE, password
   if ldap.bind
    @point_person = PointPerson.find_by_username(username)
    if !@point_person.nil?
     return true
    end
   else
    return false
   end
  end
 end