Small problem with developing a plugin...

Hi all

I’m developing a plugin that looks like this so far:

module ActsAsAuthenticated def self.included(base) base.extend(ClassMethods) end

module ClassMethods

  def acts_as_authenticated(options = {})
    options = {
      :uid => :name
    }.merge(options)

    include(InstanceMethods)

    def authenticate(name, password)
      user = send("find_by_#{options[:uid]}".to_sym, name)

      if user
        if user.hashed_password != encrypted_password(password,

user.password_salt) user = nil end end user end end

end

end

The important line is

user = send(“find_by_#{options[:uid]}”.to_sym, name)

because I want the user of my plugin to be able to pass an optional option[:uid] to the plugin. But sadly, I get the following error:

undefined local variable or method `options’ for Member:Class

Why that? How can I achieve what I want?

Thanks Josh

First off, did you do any research into the name and funcionality? Because this already exists: http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/

As for your code, you’ve got nested methods going on here, unless there’s code you kept out of the picture. Otherwise, options is a local variable to the class method. You need to set a class method (preferrably with write_inheritable_attribute) to use it later.

Jason