UserEngine - rake bootstrap aborted

Hi there,
I’ve just installed login_engine and user_engine from the repositories,
followed the setup procedures as documented in:
vendor/plugins/user_engine/README

But I’m getting the following failure:

vince@vaio:~/Projects/Booking$ rake bootstrap
(in /home/vince/Projects/Booking)
rake aborted!
undefined method edit' for class UserController’

I’ve commented out the following:

We need to wrap around the old edit

alias :old_edit :edit

def edit

@all_roles = Role.find_all.select { |r| r.name !=

UserEngine.config(:guest_role_name) }

old_edit

end

(vendor/plugins/user_engine/app/controllers/user_controller.rb)

It appears to have worked correctly and created the the default roles.

Is this just depreciated code/bug, or will i run into problems later on?

Cheers,
-v


keys: http://codex.net/gpg.asc

You can never plan the future by the past.
– Edmund Burke

Hi Vincent,

edit following file:

$RAILS_ROOT/vendor/plugins/user_engine/app/models/permission.rb

In method synchronize_with_controllers find lines that say:

we need to load all the controllers…

controller_files.each do |file_name|

and add a sort call in the second one:

we need to load all the controllers…

controller_files.sort.each do |file_name|

Remove comments from the UserController and everything should work fine.

There is a dependency between UserEngine and LoginEngine which is not
taken
into account while loading controllers. It is just a quick hack but
works
for now.

It would be nice to have some way of specyfying dependencies between
engines… On the other side it might unnecessary complicate things.
Something to think about later :wink:

Regards,

Bragi

Never use alias or alias_method in classes that potentially can be
reloaded in
the development mode. That includes controllers, models, helpers, etc.
The
first call to alias works fine, but the second one fails just like in
your
case.

Kent.

Excellent, that worked fine, cheers.
but now I’ve encountered another problem, attempting to navigate to the
/user page fails to prompt with a login screen. The browsers
(galeon/firefox) are reporting “redirected too many times”. I have
stopped WEBrick, deleted the sessions, removed the cookies and started
over, but its still doing it.

#if bragi.ragnarson /* Dec 09, 06:36 */

Remove comments from the UserController and everything should work
On 09/12/05, Vincent AE Scott <[1][email protected]> wrote:
undefined method edit' for class UserController’
roles.
Is this just depreciated code/bug, or will i run into problems
later on?
Cheers,
-v

#endif /* [email protected] */


keys: http://codex.net/gpg.asc

Just remember, once you’re over the hill you begin to pick up speed.
– Arthur Schopenhauer

Hi,

This means that UserEngine is right now configured to request login when
you
access login page.

My first guess is to cleanup roles, permissions and users tables and
start
bootstrap again. If this will not work you will have to manually
(through
SQL interface or using rails console) add permission to ‘user/login’ to
‘Guest’ role.

Regards,
Bragi

#if bragi.ragnarson /* Dec 09, 08:17 */

Hi,
This means that UserEngine is right now configured to request login
when you access login page.
My first guess is to cleanup roles, permissions and users tables and
start bootstrap again. If this will not work you will have to manually
(through SQL interface or using rails console) add permission to
‘user/login’ to ‘Guest’ role.
Regards,
Bragi

yes, spot on again.

The permissions_roles table was empty, so i had to INSERT a row into it
as you suggested. For anyone else having the same problem:

SELECT id FROM roles WHERE name=‘Guest’; # x
SELECT id FROM permissions WHERE controller=‘user’ AND action=‘login’;

y

INSERT into permissions_roles (role_id, permission_id) VALUES ( x, y );

If i get a chance over the weekend I’ll try and take a looksee as to why
the bootstrap didn’t complete this task for me.

-v

 over, but its still doing it.
 >    # we need to load all the controllers...
 between
 >      repositories,
 >      #  def edit
 problems
 Rails mailing list
  1. mailto:[email protected]
  2. http://codex.net/gpg.asc
  3. mailto:[email protected]
  4. http://lists.rubyonrails.org/mailman/listinfo/rails

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

#endif /* [email protected] */


keys: http://codex.net/gpg.asc

Brain: an apparatus with which we think we think.
– Ambrose Bierce

I have found it is an issue with needing to save the role before the
permissions are added. I created a new rake file for the bootstrap to
fix
this, but have not yet submitted it.

Below you will find new code for only the :create_roles task
plugins/user_engine/tasks/user_engine.rake


desc ‘Create the default roles’
task :create_roles => :environment do

Create the Guest Role

if Role.find_by_name(UserEngine.config(:guest_role_name)) == nil
puts “Creating guest role ‘#{UserEngine.config(:guest_role_name)}’”
guest = Role.new
guest.name = UserEngine.config(:guest_role_name)
guest.description = “Implicit role for all accessors of the site”
guest.system_role = true
guest.omnipotent = false
guest.save

guest.permissions << 

Permission.find_by_controller_and_action(‘user’,
‘login’)
guest.permissions <<
Permission.find_by_controller_and_action(‘user’,
‘forgot_password’)
guest.permissions <<
Permission.find_by_controller_and_action(‘user’,
‘signup’)
end

@all_action_permissions = Permission.find_all

Create the Admin role

if Role.find_by_name(UserEngine.config(:admin_role_name)) == nil
puts “Creating admin role ‘#{UserEngine.config(:admin_role_name)}’”
admin = Role.new
admin.name = UserEngine.config(:admin_role_name)
admin.description = “The system administrator, with REAL ULTIMATE
POWER.”
admin.omnipotent = true
admin.system_role = true

admin.save

@all_action_permissions.each { |permission|
  if !admin.permissions.include?(permission)
    admin.permissions << permission
  end
}

end

Create the User role, if needed

if Role.find_by_name(UserEngine.config(:user_role_name)) == nil
puts “Creating user role ‘#{UserEngine.config(:user_role_name)}’”
user = Role.new
user.name = UserEngine.config(:user_role_name)
user.description = “The default role for all logged-in users”
user.system_role = true
user.omnipotent = false
user.save

# all users automatically get the Guest permissions implicitly
user.permissions << Permission.find_by_controller_and_action('user',

‘logout’)
user.permissions << Permission.find_by_controller_and_action(‘user’,
‘home’)
user.permissions << Permission.find_by_controller_and_action(‘user’,
‘change_password’)
user.permissions << Permission.find_by_controller_and_action(‘user’,
‘edit’)
end
End

-Nb

 Nathaniel S. H. Brown                           http://nshb.net

Hi all

Nathaniel has been busy finding these bugs, and filing requests on the
Engines Trac site, which I’d encourage you all to peruse. I should
have a bug fix version out late next week - alas, Real Life is
forcing me to focus my energies elsewhere until then…

  • james