Forum: Ruby on Rails UserEngine - rake bootstrap aborted

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.
7f30149100d05b8869b0ca351ef9e756?d=identicon&s=25 rails (Guest)
on 2005-12-09 18:19
(Received via mailing list)
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
6578456ff00ab3520b1fe684bc572b45?d=identicon&s=25 bragi.ragnarson (Guest)
on 2005-12-09 18:39
(Received via mailing list)
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 ;)

Regards,

Bragi
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 ksruby (Guest)
on 2005-12-09 18:43
(Received via mailing list)
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.
7f30149100d05b8869b0ca351ef9e756?d=identicon&s=25 rails (Guest)
on 2005-12-09 19:48
(Received via mailing list)
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]rails@codex.net> 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 /* bragi.ragnarson@gmail.com */

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

 Just remember, once you're over the hill you begin to pick up speed.
 -- Arthur Schopenhauer
6578456ff00ab3520b1fe684bc572b45?d=identicon&s=25 bragi.ragnarson (Guest)
on 2005-12-09 20:18
(Received via mailing list)
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
7f30149100d05b8869b0ca351ef9e756?d=identicon&s=25 rails (Guest)
on 2005-12-10 12:17
(Received via mailing list)
#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
>    3. mailto:bragi.ragnarson@gmail.com
>    4. http://codex.net/gpg.asc
>    5. mailto:Rails@lists.rubyonrails.org
>    6. http://lists.rubyonrails.org/mailman/listinfo/rails

> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

#endif /* bragi.ragnarson@gmail.com */

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

 Brain: an apparatus with which we think we think.
 -- Ambrose Bierce
00e3a96684ab390a350b0271e98741d3?d=identicon&s=25 Nshbrown Nshbrown (nshb)
on 2005-12-10 15:17
(Received via mailing list)
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-12-10 21:10
(Received via mailing list)
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
This topic is locked and can not be replied to.