# LoginEngine problems

**URL:** <https://www.ruby-forum.com/t/loginengine-problems/73505>\
**Category:** Rails\
**Created:** [February 26, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/loginengine-problems/73505 "2006-02-26T17:52:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [February 26, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/1 "2006-02-26T17:52:04Z")

</div>

I’m trying to get a simple authentication system going for a small rails  
app.  
After much research, it looks like LoginEngine should do exactly what I  
want.

Now, the documentation is somewhat confusing to me when looked at in the  
light  
of reality. There are some places that say you have to install the  
“engines”  
plugin. But, I cannot find such a beast.

So, I installed the login\_engine plugin. When I try to configure it as  
it  
says, I get: “./script/…/config/…/config/environment.rb:56: undefined  
method `config’ for LoginEngine:Module (NoMethodError)”

And sure enough, if I look through the LoginEngine code, I can find no  
trace  
of a config method. So I must be missing something.

If I need the engines plugin, where can I find a released one? If it’s  
something else, what is it?

Thanks.  
David

P.S.

I’m using Rails HEAD - one week because of habtm bug that has been  
fixed, if  
that’s relevant.

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [February 26, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/2 "2006-02-26T18:39:16Z")

</div>

The specific issue you are having is because the ‘config’ method is  
provided by the engines plugin - you _need_ to install it. Normally  
that installation would be the typical one for any plugin, using the  
‘script/plugin’ command.

However, because you’re tracking the bleeding edge, you need to do a  
bit of extra work:  
[http://rails-engines.org/wiki/pages/Using+Engines+with+Edge+Rails](http://rails-engines.org/wiki/pages/Using+Engines+with+Edge+Rails)

In a nutshell, you can’t use the ‘official’ release – it works with  
the ‘official’ Rails release, and things have changed a great deal on  
the Edge. You need to do this to get the bleeding edge engines plugin:

cd vendor/plugins  
svn co [http://opensvn.csie.org/rails\_engines/engines/trunk](http://opensvn.csie.org/rails_engines/engines/trunk) engines

Also make _sure_ that you follow the instructions in the README (as  
goes for anything really) - especially because you are using Edge  
Rails.

- james

On 2/26/06, David C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m using Rails HEAD - one week because of habtm bug that has been fixed, if  
> that’s relevant.
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [March 1, 2006, 1:55am UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/3 "2006-03-01T01:55:50Z")

</div>

Well, all that make sense. However, I continue to have problems. To  
keep  
thing simple, I’ve rolled back my vendor/rails to stable, and then  
applied a  
patch for the one bug that was causing me grief (multiple HABTMs in one  
model).

Then I installed engines and login\_engine plugins in the normal way.

I followed the README to the best of my ability, and when I run any rake  
task  
(like rake import\_login\_engine\_schema, or rake engine\_info) I get this:  
undefined method `config' for Rails::Initializer::LoginEngine:Module ./config/../vendor/rails/railties/lib/initializer.rb:183:in`load\_environment’  
./config/…/vendor/rails/railties/lib/initializer.rb:155:in  
`load_environment' ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/kernel.rb:27:in`silence\_warnings’  
./config/…/vendor/rails/railties/lib/initializer.rb:152:in  
`load_environment' ./config/../vendor/rails/railties/lib/initializer.rb:81:in`process’  
./config/…/vendor/rails/railties/lib/initializer.rb:42:in `run' ./config/../config/environment.rb:10 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in`require’  
./config/…/vendor/rails/railties/lib/tasks/misc.rake:9  
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:202:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:202:in`execute’  
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:180:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:179:in`invoke’  
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:827:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:179:in`invoke’  
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:1454:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:1454:in`run’  
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/bin/rake:7  
/usr/bin/rake:18

Any pointers?  
Thanks.

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [March 1, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/4 "2006-03-01T21:12:55Z")

</div>

Two things:

1. the config method not being found indicates to me that the engines  
plugin itself isn’t being loaded

2. the fact that the error occurs for the module  
Rails::Initializer::LoginEngine makes it sound like you’ve put the  
LoginEngine config _inside_ the initializer loop.

Try moving that chunk of code, along with the Engines.start call, to  
the very bottom of your environment.rb, and in particular outside of  
any blocks.

- james

On 2/28/06, David C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ./config/…/vendor/rails/railties/lib/initializer.rb:183:in `load_environment' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:202:in `execute’  
> Any pointers?
> 
> > [http://rails-engines.org/wiki/pages/Using+Engines+with+Edge+Rails](http://rails-engines.org/wiki/pages/Using+Engines+with+Edge+Rails)  
> > Rails.
> > 
> > > “engines” plugin. But, I cannot find such a beast.
> > > 
> > > Rails mailing list
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [March 1, 2006, 9:51pm UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/5 "2006-03-01T21:51:31Z")

</div>

On Wednesday 01 March 2006 15:12, James A. wrote:

> Two things:
> 
> 1. the config method not being found indicates to me that the engines  
> plugin itself isn’t being loaded

I’m reasonably sure it is (I added a $stderr.puts), but I might have put  
it in  
the wrong place.

> 1. the fact that the error occurs for the module  
> Rails::Initializer::LoginEngine makes it sound like you’ve put the  
> LoginEngine config _inside_ the initializer loop.

I don’t have my code handy to verify, but I think it is outside the  
loop. I  
also tried saying “::LoginEngine”, and while the module name changed in  
the  
error, it did not go away.

> Try moving that chunk of code, along with the Engines.start call, to  
> the very bottom of your environment.rb, and in particular outside of  
> any blocks.

I’ll double check all of that stuff tonight though…

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [March 2, 2006, 12:52am UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/6 "2006-03-02T00:52:18Z")

</div>

If you want to add configuration in the environment/\* files, you  
unfortunately need to use the CONFIG hash directly, i.e.

module LoginEngine  
CONFIG ||= {}  
CONFIG[:salt] = ‘whatever’  
end

This is because these files are evaluated before any plugins are  
loaded, so the ‘config’ method isn’t available yet. They may also be  
evaluated within the context of Rails::Initializer, so you might need  
to address the top-level module ::LoginEngine.

- james

On 3/1/06, David C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > plugin itself isn’t being loaded
> > 
> > > this: undefined method `config' for ./config/../vendor/rails/railties/lib/initializer.rb:42:in `run’  
> > > /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:1454:in `run’
> > > 
> > > > that installation would be the typical one for any plugin, using the  
> > > > cd vendor/plugins
> > > > 
> > > > > rails app. After much research, it looks like LoginEngine should do  
> > > > > And sure enough, if I look through the LoginEngine code, I can find  
> > > > > I’m using Rails HEAD - one week because of habtm bug that has been  
> > > > > ~  
> > > > > –

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [March 2, 2006, 12:23am UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/7 "2006-03-02T00:23:22Z")

</div>

I figured it out. I also added some configuration to the  
environments/development.rb file, which is in fact the source of the  
problem.

There are a couple of things that I’d like to vary based on the  
environment?  
Short of another if statement, any suggestions?

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [March 2, 2006, 1:04am UTC](https://www.ruby-forum.com/t/loginengine-problems/73505/8 "2006-03-02T01:04:26Z")

</div>

On Wednesday 01 March 2006 03:12 pm, James A. wrote:

1. the LoginEngines Mailing list page has been spammed, making it hard  
to sign  
up (or even know who to tell).

Lastly (hah!), a few questions.

1. are the created\_at and updated\_at really necessary? Will it work fine  
without them?

2. I’m going to migrate existing user data to the LoginEngine. I  
presume I  
should set the salt column to match my configured salt. What I’d like  
to do,  
is force users to reset their passwords, by having a ‘token’ mailed to  
them.  
Any tips?

3. Is role used in any particular manner?

David
