Engines: Available in 0.14.1?

I’m a bit stuck. I’m running 0.14.1 on OS X (thank you, Locomotive). I
have
to do an simple authentication, so I figured the login_engine was worth
trying.

I read the dox

  • unzipped the engines plugin and copied the files to
    RAILS_ROOT/vendor/plugins

  • ran rake to create the rdoc

  • unzipped the login_engine plugin and copied the files to
    RAILS_ROOT/plugins/login_engine

  • modified all files as described in the doc on rubyforge

At this point, I’m still stuck at “undefined method `config’ for
LoginEngine”. Any thoughts are appreciated. Did I get the directory
structure wrong? Is there support missing in .14.1?

Thanks

Steve R. wrote:

  • unzipped the login_engine plugin and copied the files to
    RAILS_ROOT/plugins/login_engine
  • modified all files as described in the doc on rubyforge

shouldn’t this be

RAILS_ROOT/vendor/plugins/login_engine?

My typo. It’s in that directory
(RAILS_ROOT/vendor/plugins/login_engine).
Still no luck. Any other thoughts?

Thanks

Hi Steve,

There is a little more to it than just putting the engine in the plugins
folder. You have to let the app, helpers etc where to find it.

There is great installation documentation on the site
http://rails-engines.rubyforge.org/rdoc/login_engine/

This generally sets up the general Engine, but you need to look through
the
code to find out all the config options that are available.

Cheers

It sounds like the Engines plugin isn’t getting loaded. The most
common times I’ve seen this have been when I set the LoginEngine salt
in one of the config/environments/*.rb files, since they are loaded
before plugins are (and therefore the ‘config’ method doesn’t exist
yet).

You definitely have a folder /vendor/plugins/engines, with an init.rb in
it?

  • james

I received the same error you are getting until I installed the “rails
engines” plugin.

Very simple install from your root rails dir:
svn export https://opensvn.csie.org/rails_engines/plugins/engines
vendor/plugins/engines

It sounds like you’re on an older version of Rails - since we’re on
the cusp of the 1.0 revolution, Engines are tracking the latest Rails
features…

  • james

Another thing, and I’m not sure if this is because I created my
project on an older version of rails, but the
script/plugin install [-x] …
command didn’t work, due to no such script, thus my use of svn.

I also had to copy login_engine/tasks/tasks.rake to
lib/tasks/login_engine_tasks.rake to enable the
import_login_engine_schema task. Possibly this would have been done
automatically as part of the plugin install script.

After that - no worries mate :slight_smile:

Quite possible - as I’m running 0.14.1

This seems like the most likely culprit. Where do you set the salt?

james.adam wrote:

It sounds like the Engines plugin isn’t getting loaded. The most
common times I’ve seen this have been when I set the LoginEngine salt
in one of the config/environments/*.rb files, since they are loaded
before plugins are (and therefore the ‘config’ method doesn’t exist
yet).

You definitely have a folder /vendor/plugins/engines, with an init.rb in
it?

  • james

Checked the README files? :wink:

Your environment.rb file should in end something like:

module LoginEngine
config :salt, “put your unique salt value here”
end

Engines.start :login

… or something. But really, it’s all in the README files for the
engines plugin and the login engine.

  • james

Honest to gosh, I copied and pasted from the README, then changed

config :salt, “put your unique salt value here”

so that I was using my salt.

As I said in my original mail, I changed all the files as per the dox.
Where
it’s complaining is when I reopen LoginEngine and call config.
Evidently,
LoginEngine was not loaded first, so there is no ‘config’ method.
There’s
the place where I was hoping someone could shine a light.

I know this is the “if you have done your due diligence and searched the
Wiki, Google, the mailing list, etc.” thing. And, I did.

I know it’s a simple thing. I just don’t see it.

Thanks

OK, lets do it by the numbers. Can you verify & double check that you
are have

I’ve added some new tarballs to the RubyForge page, but SVN really is
better at the moment for staying on top of updates.

This error you are getting indicates that the ‘config’ function hasn’t
been added to Ruby’s Module class, which basically suggests to me that
the engines plugin isn’t being loaded at all. This method will be
defined in vendor/plugins/engines/lib/ruby_extensions.rb, which should
get loaded when the init.rb file in /vendor/plugins/engines is loaded

  • to check this is happening, you can shove a ‘puts “hello from
    engines!”’ in it and ensure that you see it being outputted when you
    start script/console.

If you don’t see this being output, then it looks like the engines
plugin itself isn’t being loaded, and there’s an issue with your Rails
setup. If it does, we’ve got to look a bit more debugging to do…

  • james

james.adam wrote:

OK, lets do it by the numbers. Can you verify & double check that you
are have

I’ve added some new tarballs to the RubyForge page, but SVN really is
better at the moment for staying on top of updates.

This error you are getting indicates that the ‘config’ function hasn’t
been added to Ruby’s Module class, which basically suggests to me that
the engines plugin isn’t being loaded at all. This method will be
defined in vendor/plugins/engines/lib/ruby_extensions.rb, which should
get loaded when the init.rb file in /vendor/plugins/engines is loaded

  • to check this is happening, you can shove a ‘puts “hello from
    engines!”’ in it and ensure that you see it being outputted when you
    start script/console.

If you don’t see this being output, then it looks like the engines
plugin itself isn’t being loaded, and there’s an issue with your Rails
setup. If it does, we’ve got to look a bit more debugging to do…

  • james

I had the same exact problem that the original poster to this thread was
having. I followed the documentation in the readme and still had an
issue. It turns out that while I THOUGHT I was following the directions
clearly, I really wasn’t! :slight_smile: The solution, for me, was as follows:

The readme says to put the following at the bottom of the environment.rb
file:

module LoginEngine
config :salt, “your-salt-here”
end

Engines.start :login

By “bottom”, it really means BOTTOM! This means after “End”! While
this may make perfectly good sense to most of you out there, for those
of use new to rails (and ruby) it is an honest mistake to attempt to do
what we think is right! :slight_smile:

Hopefully this original poster solved his problem by now. Either way,
maybe this will benefit others down the road that make the same stupid
mistake that I made.

Michael

On 11/14/05, James A. [email protected] wrote:

It sounds like you’re on an older version of Rails - since we’re on
the cusp of the 1.0 revolution, Engines are tracking the latest Rails
features…

Does the login_engine tests currently work?

I believe I’ve got the newest and greatest svn versions of everything,
and running rake test_plugins fails:

joe@big:~/projects/cisv/trunk$ svn propget svn:externals vendor
rails Peak Obsession

joe@big:~/projects/cisv/trunk$ svn propget svn:externals vendor/plugins
login_engine
https://opensvn.csie.org/rails_engines/plugins/login_engine
engines
https://opensvn.csie.org/rails_engines/plugins/engines

joe@big:~/projects/cisv/trunk$ rake test_plugins
(in /home/joe/projects/cisv/trunk)
/usr/local/bin/ruby -Ilib:test
“/usr/local/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/rake_test_loader.rb”
“vendor/plugins/login_engine/test/unit/user_test.rb”
“vendor/plugins/login_engine/test/functional/user_controller_test.rb”
“vendor/plugins/engines/test/ruby_extensions_test.rb”
Loaded suite
/usr/local/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/rake_test_loader
Started
…F…E…F.F…
Finished in 0.987599 seconds.

  1. Failure:
    test_change_password_with_bad_email(UserControllerTest)
    [/home/joe/projects/cisv/trunk/config/…/vendor/rails/actionpack/lib/action_controller/deprecated_assertions.rb:23:in
    assert_session_has' ./vendor/plugins/login_engine/test/functional/user_controller_test.rb:414:in test_change_password_with_bad_email’]:
    <:user> is not in the session
    <#<ActionController::TestSession:0x2aaaac48f5b0
    @attributes={:user=>nil, “flash”=>{}}>>

  2. Error:
    test_delete(UserControllerTest):
    NoMethodError: You have a nil object when you didn’t expect it!
    The error occured while evaluating nil.deleted=
    /home/joe/projects/cisv/trunk/vendor/plugins/login_engine/app/controllers/user_controller.rb:206:in
    restore_deleted' /home/joe/projects/cisv/trunk/config/../vendor/rails/actionpack/lib/action_controller/base.rb:854:in perform_action_without_filters’
    /home/joe/projects/cisv/trunk/config/…/vendor/rails/actionpack/lib/action_controller/filters.rb:332:in
    perform_action_without_benchmark' /home/joe/projects/cisv/trunk/config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in perform_action_without_rescue’
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in measure' /home/joe/projects/cisv/trunk/config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in perform_action_without_rescue’
    /home/joe/projects/cisv/trunk/config/…/vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in
    perform_action' /home/joe/projects/cisv/trunk/config/../vendor/rails/actionpack/lib/action_controller/base.rb:369:in process_without_session_management_support’
    /home/joe/projects/cisv/trunk/config/…/vendor/rails/actionpack/lib/action_controller/session_management.rb:116:in
    process_without_test' /home/joe/projects/cisv/trunk/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:16:in process’
    /home/joe/projects/cisv/trunk/config/…/vendor/rails/actionpack/lib/action_controller/test_process.rb:300:in
    process' /home/joe/projects/cisv/trunk/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:307:in post’
    ./vendor/plugins/login_engine/test/functional/user_controller_test.rb:255:in
    `test_delete’

  3. Failure:
    test_forgot_password(UserControllerTest)
    [/home/joe/projects/cisv/trunk/config/…/vendor/rails/actionpack/lib/action_controller/deprecated_assertions.rb:23:in
    `assert_session_has’
    ./vendor/plugins/login_engine/test/functional/user_controller_test.rb:461:in
    `do_forgot_password’
    ./vendor/plugins/login_engine/test/functional/user_controller_test.rb:431:in
    `test_forgot_password’]:
    <:user> is not in the session
    <#<ActionController::TestSession:0x2aaaac4902d0
    @attributes=
    {“return-to”=>“/bogus/location”,
    “flash”=>
    {:warning=>“Password could not be changed at this time. Please
    retry.”}}>>

  4. Failure:
    test_home_without_login(UserControllerTest)
    [./vendor/plugins/login_engine/test/functional/user_controller_test.rb:33]:
    Expected response to be a <:redirect>, but was <200>

35 tests, 164 assertions, 3 failures, 1 errors
rake aborted!
Command failed with status (1): [/usr/local/bin/ruby -Ilib:test
"/usr/local…]

I was the original poster and it turns out James solved my problem. To
recap: James’ advice below was right on. My Rails install was hosed so I
went through the process of uninstalling all versions of Rails,
reinstalling, and then making sure all my apps were running .14.3 (rails
.).

The other thing James did – and I can’t overemphasize how generous he
is
with his time – is look at the code and note that I had a backup
directory
under models with a user.rb in it. While I didn’t know it, Rails
actually
probes down the directory tree under models to look for … um, models.
That
meant my strategy of moving things into a backup folder under models
cause
my old definition of the class User to override the one in the engine.

That was the problem.

I’m a fan of the login engine and think it will solve a lot of needs for
right now. I’m interested in seeing how upgrades work and how role-based
authentication shakes out.

Steve