Forum: Ruby on Rails Engines: Available in 0.14.1?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7e5be8d0d2537a6f6f00aada5541881e?d=identicon&s=25 sross (Guest)
on 2005-11-14 04:15
(Received via mailing list)
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
2a0f7bd2c54fbc44329d69555b96f1c5?d=identicon&s=25 kevin.jackson (Guest)
on 2005-11-14 05:21
(Received via mailing list)
Steve Ross 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?
38f53ebf43385729eda5ff0d18483bd7?d=identicon&s=25 sross (Guest)
on 2005-11-14 07:35
(Received via mailing list)
My typo. It's in that directory
(RAILS_ROOT/vendor/plugins/login_engine).
Still no luck. Any other thoughts?

Thanks
9d1f5d2d9de70bd9a934f557dc95a406?d=identicon&s=25 Daniel ----- (liquid)
on 2005-11-14 09:02
(Received via mailing list)
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
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-14 11:06
(Received via mailing list)
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
793a1abe9d6824492dcf9aeff6a337ab?d=identicon&s=25 james.rw.walker (Guest)
on 2005-11-14 11:43
(Received via mailing list)
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
793a1abe9d6824492dcf9aeff6a337ab?d=identicon&s=25 james.rw.walker (Guest)
on 2005-11-14 12:13
(Received via mailing list)
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 :)
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-14 13:52
(Received via mailing list)
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
793a1abe9d6824492dcf9aeff6a337ab?d=identicon&s=25 james.rw.walker (Guest)
on 2005-11-14 13:55
(Received via mailing list)
Quite possible - as I'm running 0.14.1
7e5be8d0d2537a6f6f00aada5541881e?d=identicon&s=25 Steve Ross (Guest)
on 2005-11-14 19:03
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
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-14 19:09
(Received via mailing list)
Checked the README files? ;-)

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
38f53ebf43385729eda5ff0d18483bd7?d=identicon&s=25 sross (Guest)
on 2005-11-14 19:20
(Received via mailing list)
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
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-14 21:02
(Received via mailing list)
OK, lets do it by the numbers. Can you verify & double check that you
are have

* Rails 0.14.3 (and that your are using those latest gems in your
running application, or that the latest code is in your vendor/rails
directory)
* the latest Engines plugin
(https://opensvn.csie.org/rails_engines/plugins/engines)
* the latest LoginEngine plugin
(https://opensvn.csie.org/rails_engines/plugins/login_engine)

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
5565e460a42fbe5669b458b2753f8d34?d=identicon&s=25 Michael (Guest)
on 2005-11-23 05:44
james.adam wrote:
> OK, lets do it by the numbers. Can you verify & double check that you
> are have
>
> * Rails 0.14.3 (and that your are using those latest gems in your
> running application, or that the latest code is in your vendor/rails
> directory)
> * the latest Engines plugin
> (https://opensvn.csie.org/rails_engines/plugins/engines)
> * the latest LoginEngine plugin
> (https://opensvn.csie.org/rails_engines/plugins/login_engine)
>
> 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!  :-)  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!  :-)

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
7e5be8d0d2537a6f6f00aada5541881e?d=identicon&s=25 sross (Guest)
on 2005-11-23 08:00
(Received via mailing list)
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
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 joevandyk (Guest)
on 2005-11-24 04:00
(Received via mailing list)
On 11/14/05, James Adam <james.adam@gmail.com> 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 http://dev.rubyonrails.com/svn/rails/trunk

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...]
This topic is locked and can not be replied to.