Forum: Ruby on Rails UserEngine -- Permission.synchronize_with_controllers -- tro

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.
James L. (Guest)
on 2006-01-23 03:54
(Received via mailing list)
I suspect there's an easier version of this question that I could ask,
but I'm not sure where I'm going wrong.  I have LoginEngine and
UserEngine setup and seemingly running fine.  However, not all of my
controllers are being found when I run "rake sync_permissions".
Specifically, it's the controllers that are not in the base
controllers folder, but rather in a subfolder.  I have my admin
controllers separated in their own "admin" directory directly under
the normal controllers directory.

I've stepped through the Permission.synchronize_with_controllers
method with the console to try to figure out what's going on.

This line does pick up all of my controllers.

    controller_files = Dir[RAILS_ROOT +
"/app/controllers/**/*_controller.rb"]


But then this line doesn't include any of my admin controllers.

    ApplicationController.all_controllers.collect do |controller|


If I understand this correctly, ApplicationController is an instance
of my application.rb file in the controllers directory.  Yes?   Is
there something that I need to do so that it's aware of controllers in
the subdirectories?

/app/controllers/application.rb

require 'login_engine'
class ApplicationController < ActionController::Base
	include LoginEngine
	include UserEngine

	helper :user
	model :user

	before_filter :authorize_action
end

Example of one of my admin controllers.

class Admin::PlayersController < ApplicationController
  layout "admin_layout"

  #... methods here (I have several methods defined here, but figured
no one really cared to see them all  ...

end



-- James
James A. (Guest)
on 2006-01-25 18:51
(Received via mailing list)
This is a known problem; basically the methods we were using in Rails
to get all subclasses don't return any classes defined within any
modules (see a recent post by Tom W. on the Rails-core list about
this).

We should have a fixed version out very soon, but you can see the
change in the UserEngine trunk currently (in the authorized_system.rb
file, 'all_controllers' method):

http://opensvn.csie.org/rails_engines/user_engine/...

- james
James L. (Guest)
on 2006-01-25 19:00
(Received via mailing list)
On 1/25/06, James A. <removed_email_address@domain.invalid> wrote:
> This is a known problem; basically the methods we were using in Rails
> to get all subclasses don't return any classes defined within any
> modules (see a recent post by Tom W. on the Rails-core list about
> this).
>
> We should have a fixed version out very soon, but you can see the
> change in the UserEngine trunk currently (in the authorized_system.rb
> file, 'all_controllers' method):

That sounds great.  I ended up just moving my controllers out of their
modules and into the base controller directory.  No big deal, really,
but it's good to know that this will be supported in the future.

Thanks!

-- James
This topic is locked and can not be replied to.