# Small problem with developing a plugin

**URL:** <https://www.ruby-forum.com/t/small-problem-with-developing-a-plugin/121330>\
**Category:** Rails\
**Created:** [November 26, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/small-problem-with-developing-a-plugin/121330 "2007-11-26T22:55:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [November 26, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/small-problem-with-developing-a-plugin/121330/1 "2007-11-26T22:55:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [November 26, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/small-problem-with-developing-a-plugin/121330/2 "2007-11-26T23:12:28Z")

</div>

On Nov 26, 2007 4:55 PM, Joshua M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> module ClassMethods  
> if user.hashed\_password != encrypted\_password(password,  
> The important line is  
> 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/](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
